
-Code
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class BOJ24795 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int Y = sc.nextInt();
// 장애물 중복 제거를 위한 set
Set<Integer> found = new HashSet<>();;
// 넘어야할 장애물
for (int i = 0; i < Y; i++) {
found.add(sc.nextInt());
}
// 출력
for (int i = 0; i < N; i++) {
if (!found.contains(i)) {
System.out.println(i);
}
}
System.out.println("Mario got " + found.size() + " of the dangerous obstacles.");
}
}'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
| [프로그래머스/Java] 2 x n 타일링 (0) | 2025.10.13 |
|---|---|
| [백준/Java] 34302번 Win Streak (0) | 2025.10.13 |
| [백준/Java] 11724번 연결 요소의 개수 (0) | 2025.10.01 |
| [백준/Java] 2750번 소트인사이드 (0) | 2025.09.26 |
| [백준/Java] 2750번 수 정렬하기 (0) | 2025.09.26 |