Skip to content

Commit 15ae99e

Browse files
committed
[level 0] Title: 짝수 홀수 개수, Time: 0.02 ms, Memory: 84.4 MB -BaekjoonHub
1 parent 4c64141 commit 15ae99e

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# [level 0] 짝수 홀수 개수 - 120824
2+
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/120824)
4+
5+
### 성능 요약
6+
7+
메모리: 84.4 MB, 시간: 0.02 ms
8+
9+
### 구분
10+
11+
코딩테스트 연습 > 코딩테스트 입문
12+
13+
### 채점결과
14+
15+
정확성: 100.0<br/>합계: 100.0 / 100.0
16+
17+
### 제출 일자
18+
19+
2026년 04월 18일 11:21:53
20+
21+
### 문제 설명
22+
23+
<p>정수가 담긴 리스트&nbsp;<code>num_list</code>가 주어질 때, <code>num_list</code>의 원소 중 짝수와 홀수의 개수를 담은 배열을 return 하도록 solution 함수를 완성해보세요.</p>
24+
25+
<hr>
26+
27+
<h5>제한사항</h5>
28+
29+
<ul>
30+
<li>1 ≤ <code>num_list</code>의 길이 ≤ 100</li>
31+
<li>0 ≤ <code>num_list</code>의 원소 ≤ 1,000</li>
32+
</ul>
33+
34+
<hr>
35+
36+
<h5>입출력 예</h5>
37+
<table class="table">
38+
<thead><tr>
39+
<th>num_list</th>
40+
<th>result</th>
41+
</tr>
42+
</thead>
43+
<tbody><tr>
44+
<td>[1, 2, 3, 4, 5]</td>
45+
<td>[2, 3]</td>
46+
</tr>
47+
<tr>
48+
<td>[1, 3, 5, 7]</td>
49+
<td>[0, 4]</td>
50+
</tr>
51+
</tbody>
52+
</table>
53+
<hr>
54+
55+
<h5>입출력 예 설명</h5>
56+
57+
<p>입출력 예 #1</p>
58+
59+
<ul>
60+
<li>[1, 2, 3, 4, 5]에는 짝수가 2, 4로 두 개, 홀수가 1, 3, 5로 세 개 있습니다.</li>
61+
</ul>
62+
63+
<p>입출력 예 #2</p>
64+
65+
<ul>
66+
<li>[1, 3, 5, 7]에는 짝수가 없고 홀수가 네 개 있습니다.</li>
67+
</ul>
68+
69+
70+
> 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public int[] solution(int[] num_list) {
3+
int[] answer = new int[2];
4+
5+
for(int i=0; i<num_list.length; i++){
6+
if(num_list[i] %2 == 0) answer[0]++;
7+
else answer[1]++;
8+
}
9+
10+
return answer;
11+
}
12+
}

0 commit comments

Comments
 (0)