class Solution {
public boolean canJump(int[] nums) {
int i = 0;
for (int reach = 0; i < nums.length && i <= reach; ++i)
reach = Math.max(reach, i + nums[i]);
return i == nums.length;
}
}
leetcode
challenge
Here is the link for the problem:
https://leetcode.com/problems/jump-game/
Top comments (0)