Skip to content

Commit 1bc346c

Browse files
committed
Time: 2 ms (68.27%), Space: 52.7 MB (96%) - LeetHub
1 parent 53a0df8 commit 1bc346c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

0055-jump-game/0055-jump-game.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {boolean}
4+
3, 2, 1, 0, 4
5+
3 3 3 x
6+
7+
*/
8+
var canJump = function (nums) {
9+
let maxDestination = 0;
10+
for (let i = 0; i < nums.length; i++) {
11+
if (maxDestination < i) {
12+
return false;
13+
}
14+
maxDestination = Math.max(nums[i] + i, maxDestination);
15+
}
16+
return true;
17+
};

0 commit comments

Comments
 (0)