Merge pull request #1888 from ZerenZhang2022/patch-8

Update 0045.跳跃游戏II.md
This commit is contained in:
程序员Carl 2023-02-08 10:04:09 +08:00 committed by GitHub
commit 1279d836fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

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