parent
2ff490eb2f
commit
700b5c388b
|
|
@ -231,6 +231,21 @@ class Solution:
|
|||
step += 1
|
||||
return step
|
||||
```
|
||||
```python
|
||||
# 贪心版本三 - 类似‘55-跳跃游戏’写法
|
||||
class Solution:
|
||||
def jump(self, nums) -> int:
|
||||
if len(nums)==1: return 0
|
||||
i = 0
|
||||
count = 0
|
||||
cover = 0
|
||||
while i<=cover:
|
||||
for i in range(i,cover+1):
|
||||
cover = max(nums[i]+i,cover)
|
||||
if cover>=len(nums)-1: return count+1
|
||||
count+=1
|
||||
|
||||
```
|
||||
|
||||
```python
|
||||
# 动态规划做法
|
||||
|
|
|
|||
Loading…
Reference in New Issue