452. Minimum Number of Arrows to Burst Balloons
https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/description/
/*
* @lc app=leetcode id=452 lang=cpp
*
* [452] Minimum Number of Arrows to Burst Balloons
*/
// @lc code=start
class Solution {
public:
int findMinArrowShots(vector<vector<int>>& points) {
if (points.empty()) return 0;
sort(points.begin(), points.end(), [](const auto &a, const auto &b){
return a[1] < b[1];
});
int res = 1, end = points[0][1];
for (const auto &p : points) {
if (p[0] <= end) continue;
++res;
end = p[1];
}
return res;
}
};
// @lc code=end
Last updated