Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5a38e7

Browse files
authored
Merge pull request neetcode-gh#341 from aartiiyer90/main
Create 55-Jump-Game.js
2 parents 78b0609 + 5c80ed1 commit d5a38e7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

javascript/55-Jump-Game.js

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

0 commit comments

Comments
 (0)