0
点赞
收藏
分享

微信扫一扫

452. 用最少数量的箭引爆气球

Go_Viola 2022-07-29 阅读 46


452. 用最少数量的箭引爆气球_i++

class Solution {
public int findMinArrowShots(int[][] points) {
if(points.length == 0) return 0;
Arrays.sort(points, (p1, p2) -> p1[1] < p2[1] ? -1 : 1);
int res = 1;
int pre = points[0][1];
for (int i = 1; i < points.length; i++) {
if (points[i][0] > pre) {
res++;
pre = points[i][1];
}
}
return res;

}
}

 

举报

相关推荐

0 条评论