public static int jump(int[] A) {
        // write your code here
        if (A.length==1)
            return 0;
        int mr=0,i=0,j=0;
        while (true) {
            for (int pr=mr;i<A.length&&i<=pr;++i) {
                mr=Math.max(mr,i+A[i]);
            }
            ++j;
            if (mr>=A.length-1) {
                return j;
            }
        }
    }