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
- Class
- Number Theory
- Counting
- 코테
- Method
- 파이썬
- SQL
- geometry
- string
- hash table
- java
- sorting
- greedy
- Tree
- Data Structure
- Math
- two pointers
- implement
- array
- Matrix
- simulation
- database
- 구현
- dynamic programming
- 자바
- Binary Search
- Stack
- 코딩테스트
- bit manipulation
- Binary Tree
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] 짝수는 싫어요 본문
1. Input
1) 정수 n
2. Output
1) n 이하의 홀수가 오름차순으로 담긴 배열
3. Constraint
1) 1<= n <= 100
4. Example
Input: n=10 -> Output: {1,3,5,7,9}
5. Code
1) 첫 코드(2022/10/18)
int len = n%2==0 ? n/2 : n/2 +1;
int[] answer = new int[len];
for(int i=0 ; i<len ; i++)
answer[i] = 2*i+1;
return answer;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.0] 피자 나눠 먹기 (2) (0) | 2022.10.19 |
---|---|
[프로그래머스/Lv.0] 피자 나눠 먹기 (1) (0) | 2022.10.19 |
[프로그래머스/Lv.0] 중앙값 구하기 (0) | 2022.10.18 |
[프로그래머스/Lv.0] 나머지 구하기 (0) | 2022.10.18 |
[프로그래머스/Lv.0] 배열 두배 만들기 (0) | 2022.10.18 |