package leetcode;

/**
 * https://leetcode.com/problems/escape-a-large-maze/
 */
public class Problem1036 {
    public boolean isEscapePossible(int[][] blocked, int[] source, int[] target) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1036 prob = new Problem1036();
    }
}

@@ -12,16 +12,89 @@
 tcode;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.Stack;%0A%0A
 /**%0A * h
@@ -269,135 +269,1746 @@
     
-// TODO%0A        return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1036 prob = new Problem1036();
+Set%3CString%3E blockedSet = new HashSet%3C%3E();%0A        for (int%5B%5D b : blocked) %7B%0A            blockedSet.add(toString(b));%0A        %7D%0A        return isEscapePossible(blockedSet, source, target, 1_000_000, 1_000_000);%0A    %7D%0A%0A    private static boolean isEscapePossible(Set%3CString%3E blocked, int%5B%5D source,%0A                                            int%5B%5D target, int maxRow, int maxCol) %7B%0A        Set%3CString%3E visited = new HashSet%3C%3E();%0A        Stack%3Cint%5B%5D%3E coordinates = new Stack%3C%3E();%0A        coordinates.add(source);%0A        while (!coordinates.isEmpty()) %7B%0A            int%5B%5D pop = coordinates.pop();%0A            if (pop%5B0%5D == target%5B0%5D && pop%5B1%5D == target%5B1%5D) %7B%0A                return true;%0A            %7D%0A            if (coordinates.size() %3E= 1000) %7B%0A                return true;%0A            %7D%0A            if ((pop%5B0%5D %3C 0 %7C%7C pop%5B0%5D == maxRow) %7C%7C (pop%5B1%5D %3C 0 %7C%7C pop%5B1%5D == maxCol)) %7B%0A                continue;%0A            %7D%0A            String key = toString(pop);%0A            if (blocked.contains(key) %7C%7C visited.contains(key)) %7B%0A                continue;%0A            %7D%0A            visited.add(key);%0A            for (int%5B%5D a : new int%5B%5D%5B%5D%7B%7B0, 1%7D, %7B1, 0%7D, %7B0, -1%7D, %7B-1, 0%7D%7D) %7B%0A                coordinates.add(new int%5B%5D%7Bpop%5B0%5D + a%5B0%5D, pop%5B1%5D + a%5B1%5D%7D);%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%0A    private static String toString(int%5B%5D a) %7B%0A        return a%5B0%5D + %22,%22 + a%5B1%5D;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1036 prob = new Problem1036();%0A        System.out.println(prob.isEscapePossible(%0A            new int%5B%5D%5B%5D%7B%7B0, 1%7D, %7B1, 0%7D%7D, new int%5B%5D%7B0, 0%7D, new int%5B%5D%7B0, 2%7D)); // false%0A        System.out.println(prob.isEscapePossible(%0A            new int%5B%5D%5B%5D%7B%7D, new int%5B%5D%7B0, 0%7D, new int%5B%5D%7B999999,999999%7D)); // true
 %0A   

Update problem 1036