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
- 파이썬
- Binary Tree
- simulation
- Number Theory
- geometry
- SQL
- Stack
- implement
- database
- hash table
- Method
- Counting
- sorting
- Math
- 구현
- java
- Binary Search
- Matrix
- bit manipulation
- 자바
- dynamic programming
- greedy
- array
- 코테
- 코딩테스트
- string
- two pointers
- Data Structure
- Tree
Archives
- Today
- Total
코린이의 소소한 공부노트
[프로그래머스/Lv.0] 배열의 원소 삭제하기 본문
1. Input, Output, Example

- arr의 원소 중 delete_list의 원소를 모두 삭제하고 남은 원소들은 기존의 arr에 있던 순서를 유지한 배열을 반환
2. Constraint
1) 1 ≤ arr의 길이 ≤ 100
2) 1 ≤ arr의 원소 ≤ 1,000
3) arr의 원소는 모두 서로 다르다.
4) 1 ≤ delete_list의 길이 ≤ 100
5) 1 ≤ delete_list의 원소 ≤ 1,000
6) delete_list의 원소는 모두 서로 다르다.
3. Code
1) 첫 코드(2023/04/25)
import java.util.*;
class Solution {
public int[] solution(int[] arr, int[] delete_list) {
HashSet<Integer> set = new HashSet<>();
for(int i : delete_list)
set.add(i);
ArrayList<Integer> list = new ArrayList<>();
for(int i : arr)
if(!set.contains(i))
list.add(i);
int[] answer = new int[list.size()];
for(int i=0 ; i<list.size() ; i++)
answer[i] = list.get(i);
return answer;
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[프로그래머스/Lv.0] 배열 만들기 2 (0) | 2023.04.25 |
---|---|
[프로그래머스/Lv.0] 홀수 vs 짝수 (0) | 2023.04.25 |
[프로그래머스/Lv.0] ad 제거하기 (0) | 2023.04.25 |
[프로그래머스/Lv.0] 할 일 목록 (0) | 2023.04.25 |
[프로그래머스/Lv.0] 마지막 두 원소 (0) | 2023.04.25 |