@@ -0,0 +1,1448 @@
+/**%0A *%09Given 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 *%09Determine if you are able to reach the last index.%0A *%0A *%09For example:%0A *%09A = %5B2,3,1,1,4%5D, return true.%0A *%0A *%09A = %5B3,2,1,0,4%5D, return false.%0A *%0A *%09Author: matao%0A *%0A */%0A%0Apublic class JumpGame %7B%0A%09// dynamic programming     timeout%0A%09public static boolean canJump1(int%5B%5D nums) %7B%0A%09%09if(nums == null %7C%7C nums.length == 0) %7B%0A%09%09%09return false;%0A%09%09%7D   %0A%09%09boolean%5B%5D can = new boolean%5Bnums.length%5D;%0A%09%09can%5B0%5D = true;%0A%09%09for (int i = 1; i %3C nums.length; i++) %7B%0A%09%09%09for (int j = 0; j %3C i; j++) %7B%0A%09%09%09%09if(can%5Bj%5D && j + nums%5Bj%5D %3E= i) %7B   // j%E6%9C%AC%E8%BA%AB%E5%8F%AF%E8%BE%BE%EF%BC%8C%E4%B8%94%E5%9C%A8j%E5%A4%84%E8%B7%B3j%E7%9A%84%E6%9C%80%E5%A4%A7%E6%AD%A5%E5%B9%85%E5%A4%A7%E4%BA%8Ei%EF%BC%8C%E5%88%99i%E4%B9%9F%E5%8F%AF%E8%BE%BE%0A%09%09%09%09%09can%5Bi%5D = true;%0A%09%09%09%09%09break;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return can%5Bnums.length - 1%5D;%0A    %7D%0A%0A    // greedy%0A    public static boolean canJump2(int%5B%5D nums) %7B%0A    %09if(nums == null %7C%7C nums.length == 0) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%09int maxStep = nums%5B0%5D;%0A%09%09for (int i = 1; i %3C nums.length; i++) %7B%0A%09%09%09if(i %3C= maxStep && i + nums%5Bi%5D %3E= maxStep) %7B%0A%09%09%09%09maxStep = i + nums%5Bi%5D;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return maxStep %3E= nums.length - 1;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A    %09int%5B%5D nums1 = %7B2, 3, 1, 1, 4%7D;%0A    %09int%5B%5D nums2 = %7B3, 2, 1, 0, 4%7D;%0A    %09System.out.println(canJump1(nums1));%0A    %09System.out.println(canJump1(nums2));%0A%0A    %09System.out.println(canJump2(nums1));%0A    %09System.out.println(canJump2(nums2));%0A    %7D%0A%7D

add Jump Game solution