题目
代码
class Solution {
public int findMinArrowShots(int[][] points) {
if (points.length == 0 || points == null) return 0;
Arrays.sort(points, new Comparator<int[]>() {
@Override
public int compare(int[] o1, int[] o2) {
// return o1[1] - o2[1];
return (o1[1] < o2[1]) ? -1 :(o1[1] > o2[1] ? 1: 0);
}
});
int cnt = 1;
int end = points[0][1];
for (int i = 1; i < points.length; i++) {
if (points[i][0] <= end)
continue;
cnt++;
end = points[i][1];
}
return cnt;
}
}