[프로그래머스 | Lv.0] 짝수 홀수 개수

이승민·2023년 7월 24일
0

프로그래머스

목록 보기
6/27

https://school.programmers.co.kr/learn/courses/30/lessons/120824

📝 나의 풀이

using System;

public class Solution {
    public int[] solution(int[] num_list) {

        int count1=0;
        int count2=0;

        for(int i=0; i<num_list.Length;i++){
            if(num_list[i]%2==0){
                count1++;
            } else count2++;}
            
         int[] answer = new int[] {count1,count2};
        
        return answer;
    }
}

0개의 댓글

관련 채용 정보