package leetcode;

/**
 * https://leetcode.com/problems/jump-game-iii/
 */
public class Problem1306 {
    public boolean canReach(int[] arr, int start) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1306 prob = new Problem1306();
        System.out.println(prob.canReach(new int[]{4,2,3,0,3,1,2}, 5)); // true
        System.out.println(prob.canReach(new int[]{4,2,3,0,3,1,2}, 0)); // true
        System.out.println(prob.canReach(new int[]{3,0,2,1,2}, 2)); // false
    }
}

@@ -159,36 +159,60 @@
     
-// TODO%0A        return false
+return canReach(arr, start, new boolean%5Barr.length%5D)
 ;%0A  
@@ -225,21 +225,22 @@
    p
-ublic
+rivate
  static 
 void
@@ -239,160 +239,230 @@
 tic 
-void main(String%5B%5D args) %7B%0A        Problem1306 prob = new Problem1306();%0A        System.out.println(prob.canReach(new int%5B%5D%7B4,2,3,0,3,1,2%7D, 5)); //
+boolean canReach(int%5B%5D arr, int index, boolean%5B%5D visited) %7B%0A        if (visited%5Bindex%5D) %7B%0A            return false;%0A        %7D%0A        if (arr%5Bindex%5D == 0) %7B%0A            return true;%0A        %7D%0A        visited%5Bindex%5D =
  true
+;
 %0A   
@@ -470,156 +470,226 @@
     
-System.out.println(prob.canReach(new int%5B%5D%7B4,2,3,0,3,1,2%7D, 0)); // true%0A        System.out.println(prob.canReach(new int%5B%5D%7B3,0,2,1,2%7D, 2)); // false
+boolean a = index + arr%5Bindex%5D %3C arr.length ? canReach(arr, index + arr%5Bindex%5D, visited) : false;%0A        boolean b = index - arr%5Bindex%5D %3E= 0 ? canReach(arr, index - arr%5Bindex%5D, visited) : false;%0A        return a %7C%7C b;
 %0A   

Solve problem 1306