mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
Update 0452.用最少数量的箭引爆气球.md
增加 python 不改变原数组 写法
This commit is contained in:
@ -177,7 +177,23 @@ class Solution:
|
|||||||
points[i][1] = min(points[i - 1][1], points[i][1]) # 更新重叠气球最小右边界
|
points[i][1] = min(points[i - 1][1], points[i][1]) # 更新重叠气球最小右边界
|
||||||
return result
|
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
|
||||||
```go
|
```go
|
||||||
func findMinArrowShots(points [][]int) int {
|
func findMinArrowShots(points [][]int) int {
|
||||||
|
Reference in New Issue
Block a user