当前位置:网站首页>1232 · 爆破气球的最小箭头数
1232 · 爆破气球的最小箭头数
2022-04-22 06:16:00 【yinhua405】
描述
在二维空间中有许多球形气球。 对于每个气球,提供的输入是水平直径的起点和终点坐标。 由于它是水平的,因此y坐标无关紧要,因此直径的起点和终点的x坐标就足够了。 起点总是小于终点。 最多将有10^4个气球。
可以沿x轴从不同点垂直向上发射箭头。 如果xstart≤x≤xend,则坐标为xstart和xend的气球被在x处发射的箭头戳爆。 可以发射的箭头数量没有限制。 一次射击的箭头一直无限地向上移动。 问题是要找到戳破所有气球的最小发射箭头数。
样例1
输入:
[[10,16], [2,8], [1,6], [7,12]]
输出:
2
说明:
一种方法是发射一个箭头,例如在x = 6(爆破气球[2,8]和[1,6]),发射另一个箭头在x = 11(爆破其他两个气球)。
样例2
输入:
[[1,2],[3,4],[5,6],[7,8]]
输出:
4
int findMinArrowShots(vector<vector<int>> &points) {
// Write your code here
if(0 == points.size())
{
return 0;
}
sort(points.begin(),points.end(),cmp);
int count=1;
int x=points[0][1];
for(int i=1;i<points.size();i++)
{
if(x < points[i][0])
{
x= points[i][1];
count++;
}
}
return count;
}
版权声明
本文为[yinhua405]所创,转载请带上原文链接,感谢
https://blog.csdn.net/yinhua405/article/details/122935487
边栏推荐
- [number theory] prime number (4): decomposition of numbers (Pollard rho)
- . net learning notes - about Net core (1) [. NETCORE's project structure, five ways to transfer values to pages, and the use of log4net and NLog]
- (五) 使用Navicat创建数据库数据表并设置id自增
- Error: (vlog-2892) Net type of 'i_yc422' must be explicitly declared.
- [number theory] congruence (V): multivariate linear congruence equation
- Beyond Compare“授权密钥已被吊销”的解决办法
- Complete a student information management system and systematically practice object-oriented, function, string and other knowledge. Realize the comprehensive application of knowledge. Use classes, fun
- synchronized锁优化的一些机制(锁升级)
- (二)Sql Server的基本配置以及使用Navicat连接Sql Server
- ERROR: [Hsi 55-1545] ,无法正常生成fsbl,Unable to read in MSS file,Failed to closesw system.mss
猜你喜欢

Define a student class 1 to get the student's name: get_ Name() return type: STR 2 get student's age: get_ Age() return type: int 3 returns the highest score among the three subjects. get_ course()
![[DRC RTSTAT-1] Unrouted nets: 1 net(s) are unrouted](/img/bf/0851c85f766432f6d6306d52e67188.png)
[DRC RTSTAT-1] Unrouted nets: 1 net(s) are unrouted

Win10 modify command line default font

Two algorithm questions for Microsoft intern interview -- 20220119

C语言 | 快速排序

Pixhawk4+Up Board / NUC Implement VIO By Deploying T265

Find a notepad file by yourself, find the data material by yourself, and count the times of three keywords or sentence entries in the whole text.

Interviewers often ask about the general process and special circumstances of object allocation

虚拟机磁盘空间缩小

Choose any novel website, crawl any novel and save it in the form of Notepad.
随机推荐
虚拟机磁盘空间缩小
Robomaster Dajiang flying hand assessment
为什么非主键索引的叶子结点存放的数据是主键值
手撕算法---LRU缓存淘汰策略,问的这么频繁
Cannot find interface mapping after updating HDF
【数论】同余(三):一元线性同余方程
What is the internal structure of stack frame?
Vivado generates and invokes EDF netlist files
【数论】欧拉函数(基本性质、递推法、公式法、线性筛法)
[number theory] congruence (V): multivariate linear congruence equation
递归找序列集合
指针 结构体 const 小结
Points for attention in Modelsim simulation acceleration
小游戏——三子棋
JVM中的逃逸分析,可以实现不在堆上分配内存
Practice of using generics and reflection (including a generic cache) -- handwritten ORM ORM framework
Idea does not display the run dashboard view window
(5) Use Navicat to create database data table and set ID auto increment
(五) 使用Navicat创建数据库数据表并设置id自增
Singleton pool, singleton bean, singleton mode