452. Minimum Number of Arrows to Burst Balloons

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 Burst Balloons)