当前位置:网站首页>leetcode 452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球(中等)
leetcode 452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球(中等)
2022-07-27 21:43:00 【InfoQ】
一、题目大意
- 在x = 2处发射箭,击破气球[1,2]和[2,3]。
- 在x = 4处射出箭,击破气球[3,4]和[4,5]。
- 1 <= points.length <= 105
- points[i].length == 2
- -231 <= xstart < xend <= 231 - 1
二、解题思路
三、解题方法
3.1 Java实现
public class Solution {
public int findMinArrowShots(int[][] points) {
// 二维数组的排序??
Arrays.sort(points, Comparator.comparingInt(o -> o[1]));
int res = 1;
int end = points[0][1];
for (int i = 1; i < points.length; i++) {
if (points[i][0] <= end) {
end = Math.min(end, points[i][1]);
} else {
res++;
end = points[i][1];
}
}
return res;
}
}
四、总结小记
- 2022/7/27 恢复每日一题
边栏推荐
- Edit the copy and paste judgment problem (bug?), WYSIWYG display symbol problem feedback.
- What a beautiful rainbow
- 永州二恶英实验室建设细节查看
- 【zer0pts CTF 2022】 Anti-Fermat
- If we were the developer responsible for repairing the collapse of station B that night
- liux常用命令(查看及其开放防火墙端口号+查看及其杀死进程)
- 永州植物细胞实验室建设布局方案
- BUUCTF-bbbbbbrsa
- 论文写作全攻略|一篇学术科研论文该怎么写
- ESP8266-----MQTT云下设备上云
猜你喜欢

Yuanuniverse office, the ultimate dream of migrant workers

Unity implements simple Sketchpad drawing function (notes)
![[development tutorial 11] crazy shell arm function mobile phone timer experimental tutorial](/img/b2/9f046e6251366c980cc2aa3b71116f.png)
[development tutorial 11] crazy shell arm function mobile phone timer experimental tutorial

北欧岗位制博士申请有多难?

A great thinking problem cf1671d insert a progression

30余年的元宇宙,为我们带来了什么?

How Flink uses savepoint

Notes on Shangpin project in shangsilicon Valley (I)

抖音直播监控-循环值守24小时-直播弹幕

【zer0pts CTF 2022】 Anti-Fermat
随机推荐
元宇宙办公,打工人的终极梦想
BUUCTF-RSA roll
Latex common summary (2): input matrix (input matrix, diagonal matrix, equations, etc.)
新媒体内容输出方式-短视频
BUUCTF-[BJDCTF2020]RSA1
[NCTF2019]babyRSA1
2022/7/26
BUUCTF-bbbbbbrsa
ESP8266-----MQTT云下设备上云
[GWCTF 2019]枯燥的抽奖
View the construction details of Yongzhou dioxin Laboratory
[roarctf2019] babyrsa Wilson theorem
require、loadfile、dofile、load、loadstring
【zer0pts CTF 2022】 Anti-Fermat
看知名企业们如何利用 Web3进行产业重塑
Remote monitoring of pump station
14、 C pointer explanation (IV): pointer of pointer
【读书会第13期】音视频文件的封装格式
Shell(3)
Liux common commands (view and open firewall port number + view and kill process)