@@ -0,0 +1,1088 @@
+/***%0A * Given an array of non-negative integers, you are initially positioned at the first index of the array.%0A *%0A * Each element in the array represents your maximum jump length at that position.%0A *%0A * Your goal is to reach the last index in the minimum number of jumps.%0A *%0A * For example:%0A * Given array A = %5B2,3,1,1,4%5D%0A *%0A * The minimum number of jumps to reach the last index is 2. (Jump 1 step from index 0 to 1, then 3 steps to the last index.)%0A */%0Apublic class Solution %7B%0A    // Solution 1: O(n), O(1)%0A    // %5Bleft, right%5D contains currently reachable,but not %0A    // visited indexes.%0A    public int jump(int%5B%5D A) %7B%0A        if (A.length %3C= 1) return 0;%0A        int left = 0;%0A        int right = 0;%0A        int step = 0;%0A        while (left %3C= right) %7B%0A            step++;%0A            int old_right = right;%0A            for (int i = left; i %3C= old_right; ++i) %7B%0A                right = i + A%5Bi%5D %3E right ? i + A%5Bi%5D: right;%0A                if (right %3E= A.length - 1)%0A                    return step;%0A            %7D%0A            left = old_right + 1;%0A        %7D%0A        return 0;%0A    %7D%0A%7D%0A

add JumpGameII.java