力扣第452题 用最少数量的箭引爆气球

力扣第452题 用最少数量的箭引爆气球

class Solution {
    public:
    int findMinArrowShots(vector<vector<int>>& points) 
    {
        int len = points.size();
        if (len == 0)
        {
            return 0;
        }
        sort(points.begin(), points.end(), [](const vector<int> &pl1, const vector<int> &pl2){
            return pl1[1] < pl2[1];
        });
        int arrow = 1;
        int endX = points[0][1];
        for (int i = 1; i < len; i++)
        {
            if (points[i][0] > endX)
            {
                arrow++;
                endX = points[i][1];
            }
        }
        return arrow;
    }
};
原文地址:https://www.cnblogs.com/woodjay/p/12387389.html