class Solution{
public int solution(int[] num_list){
int answer = 0;
String odd = "":
String even = "";
for (int i = 0; i < num_list.length; i++){
if(num_list[i] % 2 == 0){
even = even + Integer.toString(num_list[i]);
// even = Integer.toString(num_list[i]); 이렇게 할 시 매번 반복이 될 때마다
// 갱신이 되기 때문에 even 기존에 있던 수를 같이 더해야 한다.
} else {
odd = odd + Integer.toString(num_list[i]);
}
}
answer = Integer.parseInt(even) + Integer.parseInt(odd);
// 문자열을 다시 정수로 반환을 한다.
return answer;
}
}
// 문자열로 치환하는 이유 : 단순히 숫자를 더하는게 아니라 이어 붙이는 과정을 거쳐야 하기 때문