1 2 3 4 5 6 7 8 9 10 | public class Solution { public boolean canJump(int[] nums) { int maxCover = 0; for (int i = 0; i < nums.length && maxCover<nums.length-1; i++){ if (maxCover < i) return false; maxCover = Math.max(maxCover, i+nums[i]); } return true; } } |
No comments:
Post a Comment