Skip to content

Commit ea2a014

Browse files
committed
Time: 1 ms (85.61%), Space: 58 MB (94.5%) - LeetHub
source:0038b988084b955392284765a98f1f804465ca68
1 parent 4540ece commit ea2a014

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {boolean}
4+
*/
5+
var canJump = function(nums) {
6+
let goal = nums.length - 1;
7+
8+
for (let i = nums.length - 2; i >= 0; i--) {
9+
if (i + nums[i] >= goal) {
10+
goal = i;
11+
}
12+
}
13+
14+
return goal === 0;
15+
16+
};

0 commit comments

Comments
 (0)