Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- Stack
- dynamic programming
- implement
- java
- SQL
- database
- Tree
- bit manipulation
- 코테
- Counting
- sorting
- two pointers
- Class
- Matrix
- 코딩테스트
- array
- Data Structure
- 구현
- Binary Tree
- Number Theory
- string
- 자바
- 파이썬
- Math
- hash table
- simulation
- Binary Search
- Method
- greedy
- geometry
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] n보다 커질 때까지 더하기 본문
1. Input, Output, Example
- numbers의 원소를 앞에서부터 하나씩 더하다가 그 합이 n보다 커지는 순간 이때까지 더했던 원소들의 합을 반환
2. Constraint
1) 1 ≤ numbers의 길이 ≤ 100
2) 1 ≤ numbers의 원소 ≤ 100
3) 0 ≤ n < numbers의 모든 원소의 합
3. Code
1) 첫 코드(2023/04/24)
class Solution {
public int solution(int[] numbers, int n) {
int sum = 0, i = 0;
while(sum<=n && i<numbers.length)
sum += numbers[i++];
return sum;
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.0] 꼬리 문자열 (0) | 2023.04.24 |
---|---|
[프로그래머스/Lv.0] A 강조하기 (0) | 2023.04.24 |
[프로그래머스/Lv.0] 원소들의 곱과 합 (0) | 2023.04.24 |
[프로그래머스/Lv.0] 부분 문자열 (0) | 2023.04.24 |
[프로그래머스/Lv.0] 배열에서 문자열 대소문자 변환하기 (0) | 2023.04.24 |