当前位置:网站首页>leetcode452. Detonate the balloon with the minimum number of arrows
leetcode452. Detonate the balloon with the minimum number of arrows
2022-07-03 04:57:00 【Day by day, the dish chicken Jie!!】
One : The analects of Confucius
Less self touching , Thank you for your reflection , Always be alert whether you are pretending to work hard , Do you understand Will you What do you want Only myself The clearest 
Two : subject

3、 ... and : Upper code
class Solution {
public:
/** Ideas : 1. This problem is similar to non overlapping space , Let's deal with it in ascending order according to the right boundary of each balloon 2. Then we begin to compare the right boundary of the balloon with the left boundary of the next balloon , If it is bigger than it, it can be blasted with the same arrow If it's smaller than that, update the boundary At the same time, the number of bows and arrows is increased by one . */
static bool cmp(const vector<int>& v1,const vector<int>& v2) {
return v1[1] < v2[1];
}
int findMinArrowShots(vector<vector<int>>& points) {
sort(points.begin(),points.end(),cmp);
int temp = points[0][1];// The first right boundary
int count = 1;// The initial value is 1 It means that we need a bow and arrow for the first time
for(int i = 0; i < points.size(); i++) {
if(temp < points[i][0]) {
// If the right boundary of the balloon is smaller than the left boundary of the next balloon , Then add one to the number of bows and arrows
temp = points[i][1];// Also update the right boundary
count++;
}
}
return count;
}
};
边栏推荐
- STM32 reverse entry
- Preparation for school and professional cognition
- MediaTek 2023 IC written examination approved in advance (topic)
- 论文阅读_清华ERNIE
- ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
- RT thread flow notes I startup, schedule, thread
- Market status and development prospects of the global autonomous marine glider industry in 2022
- [tools run SQL blind note]
- Sprintf formatter abnormal exit problem
- [research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
猜你喜欢
![[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree](/img/0f/bc8c44aee7a2c9dccac050b1060017.jpg)
[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree

JDBC database operation

The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge

Uipath practice (08) - selector

Unity tool Luban learning notes 1

Leetcode simple question: check whether the array is sorted and rotated
![[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached](/img/95/833f5ec20207ee5d7e6cdfa7208c5e.jpg)
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
![[research materials] annual report of China's pension market in 2021 - Download attached](/img/24/622aeeb38de16ac84128b362ceeddb.jpg)
[research materials] annual report of China's pension market in 2021 - Download attached

2022-02-12 daily clock in: problem fine brush

Actual combat 8051 drives 8-bit nixie tube
随机推荐
112 stucked keyboard (20 points)
最大连续子段和(动态规划,递归,递推)
Market status and development prospect prediction of the global fire alarm sensor industry in 2022
Compile and decompile GCC common instructions
Caijing 365 stock internal reference: what's the mystery behind the good father-in-law paying back 50 million?
Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
Thesis reading_ Tsinghua Ernie
Market status and development prospect prediction of the global forward fluorescent microscope industry in 2022
[research materials] 2021 China's game industry brand report - Download attached
Shell script Basics - basic grammar knowledge
论文阅读_清华ERNIE
1114 family property (25 points)
Problems encountered in fuzzy query of SQL statements
Online VR model display - 3D visual display solution
【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令-关闭cmd窗口、退出cmd环境(exit、exit /b、goto :eof)
第十九届浙江省 I. Barbecue
Career planning of counter attacking College Students
Market status and development prospect prediction of the global autonomous hybrid underwater glider industry in 2022
Notes | numpy-10 Iterative array
论文阅读_ICD编码_MSMN