반응형
📌 문제
https://school.programmers.co.kr/learn/courses/30/lessons/181887
📌 풀이
class Solution {
public int solution(int[] num_list) {
int answer = 0;
int sum_odd =0;
int sum_even=0;
for(int i=0; i<num_list.length; i++){
if(i%2==0){
sum_odd+=num_list[i];
}
else{
sum_even+=num_list[i];
}
}
return Math.max(sum_odd,sum_even);
}
}
반응형