Skip to content

Commit f3e62ee

Browse files
author
Hieu Luong
committed
Solve problem 452 - Minimum number of arrows to burst balloons
1 parent ae70c86 commit f3e62ee

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/contest/ReadMe.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ReadMe {
2323
// bit manipulation: 1356[v] 1342[v] 1318[v] 1310[v] 371[v]
2424
// other: 913[x] 1288[v] 843[x!] 1032[v] 850[x]
2525

26-
// intervals: 546, 312, 1000, 1353, 1288, 1235, 252, 253, 495, 616, 759, 646, 435 [x]
26+
// intervals: 546, 312, 1000, 1353, 1288, 1235, 252, 253, 495, 616, 759, 646, 435, 56 [x]
2727

2828

2929
// ~: vague
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package intervals;
2+
3+
import java.util.Arrays;
4+
5+
public class Problem452_MinimumNumberOfArrowsToBurstBalloons {
6+
7+
public int findMinArrowShots(int[][] A) {
8+
Arrays.sort(A, (a, b) -> a[1]-b[1]);
9+
long burst = Long.MIN_VALUE;
10+
int res = 0;
11+
for (int[] a : A) {
12+
if (burst < a[0]) {
13+
burst = (long)a[1];
14+
res++;
15+
}
16+
}
17+
return res;
18+
}
19+
}

0 commit comments

Comments
 (0)