Beakjoon&프로그래머스/Java

[프로그래머스/Java] 이어 붙인 수

현장 2025. 2. 7. 19:43

-Code

class Solution {
    public int solution(int[] num_list) {
        String odd = "";      
        String even = "";
        
        for (int el : num_list) {
            if (el % 2 == 0) {
                even += Integer.toString(el);
            } else {
                odd += Integer.toString(el);
            }
        }
        
        return Integer.parseInt(odd) + Integer.parseInt(even);
    }
}