解题思路:
class Solution {public boolean canJump(int[] nums) {int n = nums.length;int maxReach = 0;// 正常来说每次至少跳一格,所以最多循环n次for (int i = 0; i < n; i++) {if (i > maxReach) return false;// 这种情况代表遇到了0,跳不动了if (maxReach >= n - 1) return true;maxReach = Math.max(maxReach, i + nums[i]);}return false;}
}