Skip to content

Commit 82cef7c

Browse files
committed
jump game solution
1 parent 6104a75 commit 82cef7c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

jump-game/moonjonghoo.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var canJump = function (nums) {
2+
let maxReach = 0;
3+
4+
for (let i = 0; i < nums.length; i++) {
5+
if (i > maxReach) return false;
6+
maxReach = Math.max(maxReach, i + nums[i]);
7+
}
8+
9+
return true;
10+
};

0 commit comments

Comments
 (0)