当前位置:网站首页>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;
}
};
边栏推荐
- Hire cashier (differential constraint)
- Market status and development prospect prediction of global colorimetric cup cover industry in 2022
- STM32 reverse entry
- I've seen a piece of code in the past. I don't know what I'm doing. I can review it when I have time
- 2022-02-11 daily clock in: problem fine brush
- 1115 counting nodes in a BST (30 points)
- Review the old and know the new: Notes on Data Science
- [set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa
- Blog building tool recommendation (text book delivery)
- Messy change of mouse style in win system
猜你喜欢

Concurrent operation memory interaction

On typescript and grammar

《牛客刷verilog》Part II Verilog进阶挑战

I stepped on a foundation pit today

【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令-关闭cmd窗口、退出cmd环境(exit、exit /b、goto :eof)

MPM model and ab pressure test

The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article

Thesis reading_ Chinese medical model_ eHealth

Handler understands the record

First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
随机推荐
[set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa
[USACO 2009 Dec S]Music Notes
M1 Pro install redis
Messy change of mouse style in win system
Market status and development prospects of the global automatic tea picker industry in 2022
论文阅读_中文医疗模型_ eHealth
Prepare for 2022 and welcome the "golden three silver four". The "summary of Android intermediate and advanced interview questions in 2022" is fresh, so that your big factory interview can go smoothly
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
最大连续子段和(动态规划,递归,递推)
Why does I start with =1? How does this code work?
[luatos sensor] 2 air pressure bmp180
Market status and development prospect prediction of the global autonomous hybrid underwater glider industry in 2022
Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
论文阅读_中文NLP_ELECTRA
Handling record of electric skateboard detained by traffic police
Small sample target detection network with attention RPN and multi relationship detector (provide source code, data and download)
[luatos sensor] 1 light sensing bh1750
Market status and development prospect prediction of the global forward fluorescent microscope industry in 2022
Keepalived热备与HAProxy
关于开学的准备与专业认知