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
- dynamic programming
- sorting
- bit manipulation
- Class
- Number Theory
- greedy
- hash table
- Stack
- Matrix
- 구현
- Data Structure
- geometry
- string
- Tree
- java
- Math
- two pointers
- 코딩테스트
- simulation
- Method
- array
- Counting
- Binary Tree
- 자바
- SQL
- 파이썬
- 코테
- implement
- Binary Search
- database
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] n의 배수 고르기 본문
1. Input
1) 정수 n
2) 정수 배열 numlist
2. Output
1) numlist에서 n의 배수가 아닌 수들을 제거한 배열
3. Constraint
1) 1 ≤ n ≤ 10,000
2) 1 ≤ numlist의 크기 ≤ 100
3) 1 ≤ numlist의 원소 ≤ 100,000
4. Example
Input: n=3, numlist={1,2,3,4,5,6,7} -> Output: {3,6}
5. Code
1) 첫 코드(2022/11/01)
import java.util.ArrayList;
// main()
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i=0 ; i<numlist.length ; i++)
if(numlist[i]%n==0)
list.add(numlist[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] OX퀴즈 (0) | 2022.11.01 |
---|---|
[프로그래머스/Lv.0] 자릿수 더하기 (0) | 2022.11.01 |
[프로그래머스/Lv.0] 숫자 찾기 (0) | 2022.11.01 |
[프로그래머스/Lv.0] 배열의 유사도 (0) | 2022.10.31 |
[프로그래머스/Lv.0] 문자열 계산하기 (0) | 2022.10.31 |