diff --git a/problems/0452.用最少数量的箭引爆气球.md b/problems/0452.用最少数量的箭引爆气球.md index 53eee25c..67070ba4 100644 --- a/problems/0452.用最少数量的箭引爆气球.md +++ b/problems/0452.用最少数量的箭引爆气球.md @@ -177,7 +177,23 @@ class Solution: points[i][1] = min(points[i - 1][1], points[i][1]) # 更新重叠气球最小右边界 return result ``` +```python +class Solution: # 不改变原数组 + def findMinArrowShots(self, points: List[List[int]]) -> int: + points.sort(key = lambda x: x[0]) + sl,sr = points[0][0],points[0][1] + count = 1 + for i in points: + if i[0]>sr: + count+=1 + sl,sr = i[0],i[1] + else: + sl = max(sl,i[0]) + sr = min(sr,i[1]) + return count + +``` ### Go ```go func findMinArrowShots(points [][]int) int {