내 답안
class Solution {
public int solution(int[] numbers, int n) {
int answer = 0;
for(int i = 0; i < numbers.length; i++){
answer += numbers[i];
if(answer > n){
break;
}
}
return answer;
}
}
Java
복사
다른 사람 풀이
class Solution {
public int solution(int[] numbers, int n) {
int answer = 0;
for(int i = 0; answer <= n; i++) {
answer += numbers[i];
}
return answer;
}
}
Java
복사