import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
* 最少需要跳跃几次能跳到末尾
* @param n int整型 数组A的长度
* @param A int整型一维数组 数组A
* @return int整型
*/
public int Jump (int n, int[] A) {
// write code here
int ans = 0;
int pre = 0;
int cur = 0;
for (int i = 0; i < n - 1; i++){
cur = Math.max(cur, i + A[i]);
if (i == pre){
pre = cur;
ans++;
}
}
return ans;
}
}