내 답안
class Solution {
public int solution(int[] num_list) {
int sum = 0;
int mul = 1;
int answer = 0;
for(int i = 0; i < num_list.length; i++){
if(num_list.length >= 11){
sum += num_list[i];
answer = sum;
}
else {
mul *= num_list[i];
answer = mul;
}
}
return answer;
}
}
Java
복사
다른사람 풀이
class Solution {
public int solution(int[] num_list) {
int answer = (num_list.length < 11 ? 1 : 0);
for(int i=0; i<num_list.length; i++){
if(num_list.length < 11) {
answer *= num_list[i];
}else{
answer += num_list[i];
}
}
return answer;
}
}
Java
복사