https://leetcode-cn.com/problems/jump-game-ii/
三个变量
- step: 当前最少跳几步能到i
- cur: 跳的步数不超过step, 最右能到哪
- next : 跳的步数不超过step + 1步, 最右能到哪
1) i > cur, 说明step步不足以到达i,step++, cur = next
2)i <= cur, 说明step步内能到达i, step不用++, 但要看下next能不能更新变得更大

跳0步能到0位置,
跳的步数不超过0, 最右能到0位置
跳的步数不超过1, 最右能到3位置
i来到1,之前0步能到0位置, 现在step = 1, 也就是跳一步能到什么位置,也就是之前算的next=3, 把next的值赋值给cur,
若i ≤ cur, 说明step步内还能到达i, step不用++, 但是要看一下next能不能变得更大


public int jump(int[] nums) {int step = 0;int cur = 0;int next = nums[0];for (int i = 1; i < nums.length; i++) {if (cur < i) {step++;cur = next;}next = Math.max(next, i + nums[i]);}return step;}
