class Solution {
public int solution(int[] num_list) {
int answer = 0;
int multiply = 1;
int add = 0;
for (int n : num_list) {
multiply *= n; // 모든 원소들의 곱
add += n; // 모든 원소들의 합
}
answer = multiply < Math.pow(add, 2) ? 1 : 0;
return answer;
}
}
맨날 일반 for문만 써서 for-each문 써보았다. 훨씬 짧고 좋다!!
저번에 배운 Math.pow(n, m)도 써봤다 ㅎㅎ