Hi, There!
안녕하세요, 바오밥입니다.
목차
- 문제
- 풀이
문제
문제 내용
https://school.programmers.co.kr/learn/courses/30/lessons/120824
풀이
나의 풀이
class Solution {
public int[] solution(int[] num_list) {
int oddCnt = 0;
int evenCnt = 0;
for(int n : num_list) {
if(n%2==0) evenCnt++;
if(n%2!=0) oddCnt++;
}
int[] answer = {evenCnt, oddCnt};
return answer;
}
}
'Dev > PS' 카테고리의 다른 글
[프로그래머스-코딩테스트 입문] 특정 문자 제거하기 (0) | 2023.05.20 |
---|---|
[프로그래머스-코딩테스트 입문] 문자 반복 출력하기 (0) | 2023.05.20 |
[프로그래머스-코딩테스트 입문] 직각삼각형 출력하기 (0) | 2023.05.20 |
[프로그래머스-코딩테스트 입문] 문자열 뒤집기 (0) | 2023.05.20 |
[프로그래머스-코딩 기초 트레이닝] 문자열 여러 번 뒤집기 (0) | 2023.05.20 |