452. 用最少数量的箭引爆气球
解法一:贪心
class Solution:
def findMinArrowShots(self, points: List[List[int]]) -> int:
if len(points) == 0:
return 0
points.sort(key=lambda x: x[1])
end = points[0][1]
res = 1
for p in points[1:]:
if p[0] > end:
res += 1
end = p[1]
return res最后更新于