I hate my ugly code - idea is simple
for each pos[i, j], for each four direction, count the longest increasing 1.\nloop to find the min arm\nresult is the max min arm\n\nclass Solution {\n    publi
for each pos[i, j], for each four direction, count the longest increasing 1.\nloop to find the min arm\nresult is the max min arm\n```\nclass Solution {\n    public int orderOfLargestPlusSign(int N, int[][] mines) {\n        //Sanity check\n        if (N <= 0) {\n            return 0;\n        }\n        int[][] arr = new int[N][N];\n        for (int i = 0; i < N; i++) {\n            Arrays.fill(arr[i], 1);\n        }\n        for (int i = 0; i < mines.length; i++) {\n            arr[mines[i][0]][mines[i][1]] = 0;\n        }\n        int[][] left = new int[N][N];\n        int[][] right = new int[N][N];\n        int[][] top = new int[N][N];\n        int[][] bottom = new int[N][N];\n        \n        for (int i = 0; i < N; i++) {\n            for (int j = 0; j < N; j++) {\n                if (arr[i][j] == 0) {\n                    left[i][j] = 0;\n                } else {\n                    if (i == 0) {\n                        left[i][j] = arr[i][j];\n                    } else{\n                        left[i][j] = left[i - 1][j] + 1;\n                    }\n                    \n                }\n            }\n        }\n        for (int i = N - 1; i >= 0; i--) {\n            for (int j = 0; j < N; j++) {\n                if (arr[i][j] == 0) {\n                    right[i][j] = 0;\n                } else {\n                    if (i == N - 1) {\n                        right[i][j] = arr[i][j];\n                    } else {\n                        right[i][j] = right[i + 1][j] + 1;\n                    }\n                }\n            }\n        }\n        for (int i = 0; i < N; i++) {\n            for (int j = 0; j < N; j++) {\n                if (arr[i][j] == 0) {\n                    top[i][j] = 0;\n                } else {\n                    if (j == 0) {\n                        top[i][j] = arr[i][j];\n                    } else {\n                        top[i][j] = top[i][j - 1] + 1;\n                    }\n                }\n            }\n        }\n        for (int i = 0; i < N; i++) {\n            for (int j = N - 1; j >= 0; j--) {\n                if (arr[i][j] == 0) {\n                    bottom[i][j] = 0;\n                } else {\n                    if (j == N - 1) {\n                        bottom[i][j] = arr[i][j];\n                    } else {\n                        bottom[i][j] = bottom[i][j + 1] + 1;\n                    }\n                }\n            }\n        }\n        int min = 0;\n        int max = 0;\n        for (int i = 0; i < N; i++) {\n            for (int j = 0; j < N; j++) {\n                min = Math.min(Math.min(Math.min(left[i][j], right[i][j]), top[i][j]), bottom[i][j]);\n                max = Math.max(max, min);\n                    \n            }\n        }\n        return max;\n    }\n}\n```
[]