[LeetCode]Minimum Number of Arrows to Burst Balloons

Greedy

class Solution {  
public:  
    int findMinArrowShots(vector<pair<int, int>>& points) {
        if(points.size() == 0) {
            return 0;
        }

        sort(points.begin(), points.end());

        int ans = 1;

        for(int i = 1; i < points.size(); i++) {
            if(points[i].first <= points[i - 1].second) {
                points[i].second = min(points[i - 1].second, points[i].second);
            } else {
                ans++;
            }
        }

        return ans;
    }
};