用最少数量的箭引爆气球-贪心452-python

没看答案,和重叠区间问题类似,只不过按照题意,区间首尾相接也算重叠。
class Solution:
def findMinArrowShots(self, points: List[List[int]]) -> int:
points = sorted(points, key=lambda x:[x[1], x[0]])
count = 1
end = points[0][1]

for balloon in points:
if balloon[0] > end:
count += 1
end = balloon[1]

return count

用最少数量的箭引爆气球-贪心452-python最先出现在Python成神之路

版权声明:
作者:Mr李
链接:https://www.techfm.club/p/24325.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>