Skip to content

Commit 85b5096

Browse files
authored
Create Solution.java
1 parent 4ffdfa1 commit 85b5096

File tree

1 file changed

+17
-0
lines changed
  • solution/0452.Minimum Number of Arrows to Burst Balloons

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int findMinArrowShots(int[][] points) {
3+
if (points == null || points.length == 0) {
4+
return 0;
5+
}
6+
Arrays.sort(points, Comparator.comparingInt(o -> o[1]));
7+
int res = 1;
8+
int pre = points[0][1];
9+
for (int i = 1; i < points.length; ++i) {
10+
if (points[i][0] > pre) {
11+
++res;
12+
pre = points[i][1];
13+
}
14+
}
15+
return res;
16+
}
17+
}

0 commit comments

Comments
 (0)