Merge pull request #280 from fusunx/master

0055.跳跃游戏.md Javascript
This commit is contained in:
Carl Sun 2021-05-28 21:00:20 +08:00 committed by GitHub
commit 467e673cdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -141,7 +141,20 @@ func canJUmp(nums []int) bool {
} }
``` ```
Javascript:
```Javascript
var canJump = function(nums) {
if(nums.length === 1) return true
let cover = 0
for(let i = 0; i <= cover; i++) {
cover = Math.max(cover, i + nums[i])
if(cover >= nums.length - 1) {
return true
}
}
return false
};
```
----------------------- -----------------------