LeetCode452. 用最少数量的箭引爆气球
- 题目链接
- 代码
题目链接
https://leetcode.cn/problems/minimum-number-of-arrows-to-burst-balloons/description/
代码
class Solution:
def findMinArrowShots(self, points: List[List[int]]) -> int:
if len(points) == 0:
return 0
points.sort(key=lambda x: x[0])
result = 1
for i in range(1, len(points)):
if points[i - 1][1] < points[i][0]:
result += 1
else:
points[i][1] = min(points[i][1], points[i - 1][1])
return result