mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 23:28:29 +08:00
Merge pull request #1888 from ZerenZhang2022/patch-8
Update 0045.跳跃游戏II.md
This commit is contained in:
@ -229,7 +229,19 @@ class Solution:
|
||||
step += 1
|
||||
return step
|
||||
```
|
||||
```python
|
||||
# 动态规划做法
|
||||
class Solution:
|
||||
def jump(self, nums: List[int]) -> int:
|
||||
result = [10**4+1]*len(nums)
|
||||
result[0]=0
|
||||
for i in range(len(nums)):
|
||||
for j in range(nums[i]+1):
|
||||
if i+j<len(nums): result[i+j]=min(result[i+j],result[i]+1)
|
||||
#print(result) #打印数组
|
||||
return result[-1]
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Go
|
||||
|
Reference in New Issue
Block a user