452. 用最少数量的箭引爆气球
若当前气球和上一气球重叠,就更新当前气球的最小右边界
points[i][1] = min(points[i][1],points[i-1][1]);
若不重叠,箭的数量加一
class Solution {
public:
static bool cmp(vector<int>& a,vector<int>& b)
{
return a[0]<b[0];
}
int findMinArrowShots(vector<vector<int>>& points) {
int result = 1;
sort(points.begin(),points.end(),cmp);
for(int i=1;i<points.size();i++)
{
if(points[i][0]>points[i-1][1])
result++;
else
points[i][1] = min(points[i][1],points[i-1][1]);
}
return result;
}
};