본문 바로가기

IT/코딩테스트

[Leetcode] 452. Minimum Number of Arrows to Burst Balloons

728x90

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.sort(key = lambda x: x[1])

        count = 1
        end = points[0][1]

        for i in range(1, len(points)):
            if points[i][0] > end:
                count += 1
                end = points[i][1]

        return count
728x90