LeetCode 452. Minimum Number of Arrows to Burst Balloons

題目

這裏寫圖片描述

代碼

class Solution:
    def findMinArrowShots(self, points):
        """
        :type points: List[List[int]]
        :rtype: int
        """
        count = 0
        i = 0; j = 0
        end = 0
        points = sorted(points, key = lambda x: x[1])
        while i < len(points) and j < len(points):
            if i == 0:
                end = points[i][1]
                count += 1
            elif points[i][0] > end:
                end = points[i][1]
                count += 1
            i += 1
        return count
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章