public int jump(int[] A) {
        if(A == null || A.length == 0 || A.length == 1) return 0;
        int i = 0;// i keeps the index that can reach the max position
        int res = 0;
        while(i < A.length-1){
            ++res;
            if(i + A[i] >= A.length - 1) return res;
            int k = i;
            for(int j = k+1; j <= k + A[k] && j < A.length; ++j){
                if(j+A[j] > i + A[i]){
                    i = j;
                }
            }
        }
        return res;
    }