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 |
Tags
- Method
- Tree
- Counting
- Number Theory
- Stack
- bit manipulation
- Binary Tree
- implement
- simulation
- Math
- database
- geometry
- two pointers
- array
- Data Structure
- 자바
- Binary Search
- 구현
- Matrix
- Class
- java
- 코딩테스트
- hash table
- SQL
- string
- 파이썬
- 코테
- sorting
- greedy
- dynamic programming
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] 약수 구하기 본문
1. Input
1) 정수 n
2. Output
1) n의 약수를 오름차순으로 담은 정수 배열
3. Constraint
1) 1 <= n <= 10,000
4. Example
Input: n=6 -> Output: {1,2,3,6}
5. Code
1) 첫 코드(2022/10/31)
import java.util.ArrayList;
// main()
ArrayList<Integer> list = new ArrayList();
for(int i=1 ; i<=n ; i++)
if(n%i==0)
list.add(i);
int[] answer = new int[list.size()];
for(int i=0 ; i<answer.length ; i++)
answer[i] = list.get(i);
return answer;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.0] 가장 큰 수 찾기 (0) | 2022.10.31 |
---|---|
[프로그래머스/Lv.0] 편지 (0) | 2022.10.31 |
[프로그래머스/Lv.0] 한 번만 등장한 문자 (0) | 2022.10.31 |
[프로그래머스/Lv.0] 인덱스 바꾸기 (0) | 2022.10.31 |
[프로그래머스/Lv.0] 영어가 싫어요 (0) | 2022.10.31 |