Участник:Plague rat/Minimum Number of Arrows to Burst Balloons

Материал из DISCOPAL
Перейти к: навигация, поиск

https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/

class Solution:
    def findMinArrowShots(self, points: List[List[int]]) -> int:
        if len(points) == 0:
            return 0
 
        points = sorted(points, key = lambda x: x[1])
        leftEndInd = 0
        arrowCount = 1
        for i in range(1, len(points)):
            if points[i][0] > points[leftEndInd][1]:
                arrowCount += 1
                leftEndInd = i
        return arrowCount