mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
Update 0055.跳跃游戏.md
This commit is contained in:
@ -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]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user