当前位置:网站首页>1232. Minimum number of arrows for exploding balloons
1232. Minimum number of arrows for exploding balloons
2022-04-22 07:29:00 【yinhua405】
describe
There are many two-dimensional balloons . For each balloon , The input provided is the start and end coordinates of the horizontal diameter . Because it's horizontal , therefore y The coordinates don't matter , Therefore, the starting point and ending point of the diameter x Coordinates are enough . The starting point is always less than the ending point . There will be at most 10^4 A balloon .
You can go along x The axis emits arrows vertically upward from different points . If xstart≤x≤xend, Then the coordinates are xstart and xend The balloon was in x The arrow shot at . There is no limit to the number of arrows that can be fired . The arrow of a shot keeps moving up infinitely . The problem is to find the minimum number of launch arrows that pierce all balloons .
Examples 1
Input :
[[10,16], [2,8], [1,6], [7,12]]
Output :
2
explain :
One way is to fire an arrow , For example, in x = 6( Blasting balloon [2,8] and [1,6]), Launch another arrow at x = 11( Blow up the other two balloons ).
Examples 2
Input :
[[1,2],[3,4],[5,6],[7,8]]
Output :
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://yzsam.com/2022/04/202204220613324589.html
边栏推荐
- Codeforces Round #778
- Codeforces Round #774 (Div. 2)
- Codeforces Round #588 (Div. 2) C D
- 363 · 接雨水
- 八大排序的思想及其代码
- LeetCode - 6 - (字符串相乘、下一個更大元素<ⅠⅡⅢ>、k個一組翻轉鏈錶)
- Precautions for using feign to make remote calls
- 838 · 子数组和为K
- Leetcode - 1 - (substructure, combination, spiral matrix and full arrangement of tree < Ⅰ Ⅲ >)
- C. Ducky debugging (Game 5 of 2021 training League warm-up training competition)
猜你喜欢

In the process of class loading, the allocation area of class variables is different from that of instance variables

A. Alice and Bob (game? Thinking & Violence) (2021 Niuke summer multi school training camp 1)

LeetCode - 1 - (树的子结构、组合、螺旋矩阵、全排列<ⅠⅢ>)

B. Ball Dropping (简单几何计算 / 相似三角形) (2021牛客暑期多校训练营1)

L1-071 previous life files (20 points) (similar two points)

Leetcode - 8 - (sum of three numbers, zigzag transformation, sum of two numbers < linked list >, container with the most water, letter combination of telephone number)

L2-004 is this a binary search tree? (first order input & judgment search Binary Tree & second order output)

L2-005 集合相似度(set判重)

LeetCode -3 - (字符串相加、最大连续1的个数<ⅠⅢ>、考试的最大困扰度、删除链表的倒数第N个结点)

内部类使用说明(静态、实例、局部)
随机推荐
Codeforces Round #776 (Div. 3)
E.Figure Skating (字符串排序/签到) (2021年度训练联盟热身训练赛第五场 )
并发编程的艺术(5):ReentrantLock的使用
Unknown graphics extension:. 1 jpg. }
296 · 数组去重
快排与归并排序
最小圆覆盖(计算几何基础)
L2-005 set similarity (set judgment)
Error: (vlog-2892) Net type of 'i_ yc422' must be explicitly declared.
Educational Codeforces Round 125 (Rated for Div. 2)
L2-005 集合相似度(set判重)
In the process of class loading, the allocation area of class variables is different from that of instance variables
友情链接汇总qwq
296 · array de duplication
Vivado generates and invokes EDF netlist files
内部类使用说明(静态、实例、局部)
P1095 [NOIP2007 普及组] 守望者的逃离
A. Binary seating (the fifth game of 2021 training League warm-up training competition)
抽象类和抽象方法
L2-004 is this a binary search tree? (first order input & judgment search Binary Tree & second order output)