Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 자바
- 파이썬
- greedy
- Matrix
- bit manipulation
- hash table
- 구현
- Counting
- Binary Tree
- 코테
- string
- java
- geometry
- Class
- array
- database
- SQL
- implement
- Binary Search
- two pointers
- sorting
- Number Theory
- Stack
- Data Structure
- Method
- Math
- simulation
- 코딩테스트
- dynamic programming
- Tree
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] 짝수 홀수 개수 본문
1. Input
1) 정수가 담긴 배열 num_list
2. Output
1) num_list의 원소 중 짝수와 홀수의 개수를 담은 배열
3. Constraint
1) 1 <= num_list의 길이 <= 100
2) 0 <= num_list의 원소 <= 1,000
4. Example
Input: num_list={1,2,3,4,5} -> Output: {2,3}
설명: num_list에는 짝수가 2개, 홀수가 3개 있다.
5. Code
1) 첫 코드(2022/10/20)
int[] answer = new int[2];
for(int i=0 ; i<num_list.length ; i++){
if(num_list[i]%2==0)
answer[0]++;
else
answer[1]++;
}
return answer;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.0] 특정 문자 제거하기 (0) | 2022.10.21 |
---|---|
[프로그래머스/Lv.0] 문자 반복 출력하기 (0) | 2022.10.21 |
[프로그래머스/Lv.0] 직각삼각형 출력하기 (0) | 2022.10.21 |
[프로그래머스/Lv.0] 문자열 뒤집기 (0) | 2022.10.21 |
[프로그래머스/Lv.0] 배열 뒤집기 (0) | 2022.10.20 |