55. Jump Game
class Solution {
public boolean canJump(int[] nums) {
int jumpMax =0;
for(int i = 0; i<nums.length; i++){
if (i>jumpMax) return false;
jumpMax = i+nums[i]>jumpMax? i+nums[i]: jumpMax;
}
return true;
}
}
Last updated
Was this helpful?