Jump Game LeetCode solution in JavaScript

1
var canJump = function (nums) {
2
let target = nums.length - 1;
3
let max = 0,
4
index = 0;
5

6
while (index <= target) {
7
max = Math.max(max, index + nums[index]);
8

9
if (max >= target) return true;
10

11
if (index >= max && nums[index] === 0) return false;
12

13
index++;
14
}
15

16
return false;
17
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0