当前位置:网站首页>452. detonate the balloon with the minimum number of arrows
452. detonate the balloon with the minimum number of arrows
2022-06-11 00:14:00 【anieoo】
Original link :452. Detonate the balloon with a minimum number of arrows
solution:
Greedy strategy : Sort all intervals from small to large according to the right endpoint , Select the right end of the interval to shoot each time .

class Solution {
public:
int findMinArrowShots(vector<vector<int>>& points) {
int n = points.size();
sort(points.begin(),points.end(),[](const vector<int> &a, const vector<int> &b){
return a[1] < b[1];
});
int res = 1,ed = points[0][1];
for(int i = 1;i < n;i++) {
if(points[i][0] > ed) {
res++;
ed = points[i][1];
}
}
return res;
}
};边栏推荐
- In the month of safety production, Huangpu launched a publicity campaign for gas safety in shops
- [pyGame games] here it is. This Gobang game is super A. share it with your friends~
- [database] MySQL index interview questions
- Basic introduction and core components of kubernetes
- Pseudo static setting of Typecho - starze V Club
- [pyGame games] story stream recommendation: what kind of games can you like? (devil lover, bully's wife version)
- It is said that the verification code is a barrier in the crawler. I can break through it with only five lines of code.
- About optimizing API interface response speed
- Leetcode-15 sum of three numbers
- C language file operation
猜你喜欢

Njupt Nanyou Discrete Mathematics_ Experiment 3

vtk. VTP download in JS

Compared with the "South-to-North Water Transfer", what will the "east to west" of the fire bring to cloud computing?

【JVM】垃圾回收机制

【自动回复小脚本】新年快乐,每一个字都是我亲自手打的,不是转发哦~

From the perspective of Confucius Temple IP crossover, we can see how the six walnuts become "butterflies" for the second time
![[pyGame collection] memory killing -](/img/97/10a4333662b49ac35e5b7433a5e6a4.png)
[pyGame collection] memory killing - "Childhood Games", how many shots did you get? (attach five source codes for self access)
![[JVM] garbage collection mechanism](/img/61/e7611380954cdcd316dd0e570bdf17.png)
[JVM] garbage collection mechanism

【Opencv实战】这个印章“神器”够牛,节省了时间提高了效率,厉害~(附完整源码)

IGBT and third generation semiconductor SiC double pulse test scheme
随机推荐
Bluetooth development (4) -- about flow control
[pyGame games] I'm not afraid you can't walk the maze series: the ultimate AI walks the maze. After learning, it will take you to open the door to a new world ~ (with game source code)
About optimizing API interface response speed
Method of converting file to multipartfile
Why is the website snapshot hijacked and tampered with
IGBT and third generation semiconductor SiC double pulse test scheme
[latex] latex vs Code Snippets
博文推荐|构建 IoT 应用——FLiP 技术栈简介
Shell Sort
【Pygame合集】回忆杀-“童年游戏”,看看你中几枪?(附五款源码自取)
[pyGame] stir up your brain and play the "24 o'clock" idea together ~ (awesome)
Website online customer service system Gofly source code development log - 5 Gin framework integration daemon
[pyGame games] here it is. This Gobang game is super A. share it with your friends~
The same customized right-click menu beautification on this site - Xingze V Club
[appearance detection artifact] come on, please show me your unique skill (is this appearance worthy of the audience?)
Static method static learning
[pyGame] this classic bomber super game is online. Do you love it? (source code attached)
Struggle, programmer -- Chapter 56: hard work with thousands of blows
452. 用最少数量的箭引爆气球
Lambda learning records