MCPcopy Create free account
hub / github.com/betomoedano/JavaScript-Coding-Interview-Questions / canJump

Function canJump

greedy/jump-game.js:5–18  ·  view source on GitHub ↗
(nums)

Source from the content-addressed store, hash-verified

3 * @return {boolean}
4 */
5var canJump = function (nums) {
6 var size = nums.length;
7 var step = nums[0];
8 for (var i = 1; i < size; ++i) {
9 step--;
10 if (step < 0) {
11 return false;
12 }
13 if (nums[i] > step) {
14 step = nums[i];
15 }
16 }
17 return true;
18};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected