八怪不姓丑

关注

[220113] Minimum Number of Arrows to Burst Balloons

八怪不姓丑

关注

阅读 27

2022-02-05

class Solution:
    def findMinArrowShots(self, points):

        # 按每个气球的 end 排序
        p = sorted(points, key=lambda x: x[1])
        res = 0
        arrow = p[0][0] - 1

        # 比较每个气球的 start 和 arrow
        for each in p:
            # 需要多一支箭,有效范围到 end
            if each[0] > arrow:
                res += 1
                arrow = each[1]

        return res

相关推荐

自由情感小屋

312. Burst Balloons

自由情感小屋 25 0 0

前程有光

LeetCode: 312. Burst Balloons

前程有光 80 0 0

快乐码农Alan007

LeetCode-312. Burst Balloons [C++][Java]

快乐码农Alan007 61 0 0

扬帆远航_df7c

LeetCode_Array_312. Burst Balloons 戳气球【动态规划】【Java】【困难】

扬帆远航_df7c 184 0 0

年夜雪

Leetcode 1189. Maximum Number of Balloons [Python]

年夜雪 65 0 0

yellowone

POJ 1394 Minimum Inversion Number

yellowone 70 0 0

乌龙茶3297

【leetcode_easy】1189. Maximum Number of Balloons

乌龙茶3297 69 0 0

墨香子儿

Minimum Number of Taps to Open to Water a Garden

墨香子儿 64 0 0

unadlib

hdu1394——Minimum Inversion Number

unadlib 61 0 0

大雁f

[leetcode] 1419. Minimum Number of Frogs Croaking

大雁f 21 0 0

精彩评论(0)

0 0 举报