Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const canJump = nums => {
- let maxIndex = 0;
- for (let index = 0; index < nums.length; index++) {
- if (maxIndex >= index) maxIndex = Math.max(maxIndex, nums[index] + index);
- else return false;
- }
- return maxIndex >= nums.length - 1;
- };
Add Comment
Please, Sign In to add comment