Skip to content

Commit 3b5cb6a

Browse files
authored
Merge pull request #1199 from AlgorithmWithGod/ksinji
[20251022] PGM / LV2 / 요격 시스템 / 강신지
2 parents 3f7f6c7 + 11b2e63 commit 3b5cb6a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
```java
2+
import java.util.*;
3+
4+
class Solution {
5+
public int solution(int[][] targets) {
6+
Arrays.sort(targets, (a, b) -> Integer.compare(a[1], b[1]));
7+
8+
int answer = 0;
9+
int lastEnd = Integer.MIN_VALUE;
10+
11+
for (int[] t : targets) {
12+
int s = t[0], e = t[1];
13+
if (s >= lastEnd) {
14+
answer++;
15+
lastEnd = e;
16+
}
17+
}
18+
return answer;
19+
}
20+
}
21+
```

0 commit comments

Comments
 (0)