Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 810 Bytes

452.md

File metadata and controls

40 lines (30 loc) · 810 Bytes

452 Minimum Number of Arrows to Burst Balloons

Description

link


Solution

传统滑动窗口可以解决问题,看代码


Code

O(nlogn)

class Solution:
    def findMinArrowShots(self, points: List[List[int]]) -> int:
        points.sort()
        low = 0
        high = 0
        count = 0
        if (points):
            low = points[0][0]
            high = points[0][1]
        else:
            return 0
        for point in points:
            if (point[0] > high):
                count += 1
                low = point[0]
                high = point[1]
            
            elif (point[1] < high and point[0] > low):
                high = point[1]
        return count+1