Update 0452.用最少数量的箭引爆气球.md

增加 python 不改变原数组 写法
This commit is contained in:
ZerenZhang2022
2023-04-06 23:39:05 -04:00
committed by GitHub
parent 2ff490eb2f
commit bf8c539a63

View File

@ -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 {