码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-03-01 19:33:17      阅读:60      评论:0      收藏:0      [点我收藏+]

标签:begin   pl2   for   end   png   find   info   http   cto   

力扣第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;
    }
};

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

标签:begin   pl2   for   end   png   find   info   http   cto   

原文地址:https://www.cnblogs.com/woodjay/p/12387389.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!