Skip to content

Commit 6c33729

Browse files
committed
0055.跳跃游戏.md Javascript
1 parent 395bdd7 commit 6c33729

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

problems/0055.跳跃游戏.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,20 @@ func canJUmp(nums []int) bool {
141141
}
142142
```
143143

144-
144+
Javascript:
145+
```Javascript
146+
var canJump = function(nums) {
147+
if(nums.length === 1) return true
148+
let cover = 0
149+
for(let i = 0; i <= cover; i++) {
150+
cover = Math.max(cover, i + nums[i])
151+
if(cover >= nums.length - 1) {
152+
return true
153+
}
154+
}
155+
return false
156+
};
157+
```
145158

146159

147160
-----------------------

0 commit comments

Comments
 (0)