We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 85fce18 commit 7c787b2Copy full SHA for 7c787b2
1 file changed
weekly/week06/PGS_요격시스템/JAEHEE25.java
@@ -0,0 +1,24 @@
1
+package week06.PGS_요격시스템;
2
+
3
+import java.util.*;
4
+class Solution {
5
+ public int solution(int[][] targets) {
6
+ int answer = 0;
7
+ Arrays.sort(targets, (o1, o2) -> o1[0] - o2[0]);
8
9
+ int start = -1; //현재 요격 미사일의 범위
10
+ int end = 100_000_001;
11
+ for (int i = 0; i < targets.length; i++) {
12
+ if (targets[i][0] >= end) {
13
+ answer++;
14
+ start = -1;
15
+ end = 100_000_001;
16
+ }
17
+ start = Math.max(start, targets[i][0]);
18
+ end = Math.min(end, targets[i][1]);
19
20
21
22
+ return answer;
23
24
+}
0 commit comments