依然是求不重叠区间问题,只不过这里[1,2],[2,3]算重叠区间。
class Solution { public int findMinArrowShots(int[][] points) { if(points.length==0){ return 0; } Arrays.sort(points,Comparator.comparingInt(o -> o[1])); int ans=1; int end=points[0][1]; for(int i=1;i<points.length;i++){ if(points[i][0]<=end){ continue; } ans++; end=points[i][1]; } return ans; } }