美文网首页
452. Minimum Number of Arrows to

452. Minimum Number of Arrows to

作者: 阿团相信梦想都能实现 | 来源:发表于2016-12-17 04:28 被阅读0次
class Solution(object):
    def findMinArrowShots(self, points):
        """
        :type points: List[List[int]]
        :rtype: int
        """
        #sort the coordinates by their end positions 
        points.sort(key=lambda x:x[1])
        end=float('-inf')
        res=0
        for b in points:
            if b[0]>end:
                res+=1
                end=b[1]
        return res
            

相关文章

网友评论

      本文标题:452. Minimum Number of Arrows to

      本文链接:https://www.haomeiwen.com/subject/fceomttx.html