내 답안
class Solution {
public int solution(int[] num_list) {
int answer = 0;
String result_a = "";
String result_b = "";
for(int i=0; i<num_list.length; i++){
if(num_list[i]%2 == 0){
result_a += ""+num_list[i];
}else{
result_b += ""+num_list[i];
}
}
answer = Integer.parseInt(result_a) +Integer.parseInt(result_b);
return answer;
}
}
Java
복사
다른 사람 풀이법
class Solution {
public int solution(int[] num_list) {
int answer = 0;
int even = 0;
int odd = 0;
for(int num : num_list) {
if(num % 2 == 0) {
even *= 10;
even += num;
} else {
odd *= 10;
odd += num;
}
}
answer = even + odd;
return answer;
}
}
Java
복사