Update 0055.跳跃游戏.md

This commit is contained in:
QuinnDK
2021-05-19 10:25:58 +08:00
committed by GitHub
parent 8c3d8aab25
commit b264368a89

View File

@ -122,6 +122,24 @@ class Solution:
``` ```
Go Go
```Go
func canJUmp(nums []int) bool {
if len(nums)<=1{
return true
}
dp:=make([]bool,len(nums))
dp[0]=true
for i:=1;i<len(nums);i++{
for j:=i-1;j>=0;j--{
if dp[j]&&nums[j]+j>=i{
dp[i]=true
break
}
}
}
return dp[len(nums)-1]
}
```