import java.util.*;
public class Solution {
public int Jump (int n, int[] A) {
// 0作为起始点,n-1作为终点
int step = 0; // 跨了X步
int dist = 0; // 跨了X步最远能到哪个点
int i = 0;
while (dist < n-1) {
int lastDist = dist;
// X步(i.e.上一步)能跨到的范围内
while (i <= lastDist) {
// 跨x+1步最远能到哪个点
dist = Math.max(i + A[i], dist);
i++;
}
step++;
}
return step;
}
}