55. 跳跃游戏

class Solution {public boolean canJump(int[] nums) {int n = nums.length;int farthest = 0;for (int i = 0; i < n - 1; i++) {// 不断计算能跳到的最远距离farthest = Math.max(farthest, i + nums[i]);// 可能碰到了 0,卡住跳不动了if (farthest <= i) {return false;}}return farthest >= n - 1;}}// 详细解析参见:// https://labuladong.github.io/article/?qno=55
45. 跳跃游戏 II

