Merge pull request #189 from QuinnDK/添加0050跳跃游戏Go版本

添加0050跳跃游戏Go版本
This commit is contained in:
Carl Sun
2021-05-19 11:46:44 +08:00
committed by GitHub

View File

@ -122,6 +122,24 @@ class Solution:
```
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]
}
```