452. Minimum Number of Arrows to

2016-12-17  本文已影响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
            
上一篇 下一篇

猜你喜欢

热点阅读