[프로그래머스]짝수 홀수 개수

박예림·2023년 3월 2일
0

코테

목록 보기
32/132

class Solution {
    public int[] solution(int[] num_list) {
        int[] answer = new int[2];
        int jj = 0;
        int h = 0;
        for (int i=0; i<num_list.length; i++) {
            if (num_list[i] % 2 == 0) {
                jj++;
            } else {h++;}
        }
        answer[0]=jj;
        answer[1]=h;
        return answer;
    }
}
profile
응애 나 아기개발자

0개의 댓글