Merge pull request #2013 from ZerenZhang2022/patch-25

Update 0452.用最少数量的箭引爆气球.md
This commit is contained in:
程序员Carl
2023-04-20 10:03:02 +08:00
committed by GitHub

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 {