(66ms) Easy to understand Java Solution(O(N^2) Two Pass)
In the solution we just need one 2d array grid[N][N].\n\nThe basic idea is to record the min length of 4 directions, for example:\n\t\t\t\t\t\t\n            1\n
In the solution we just need one 2d array **grid[N][N]**.\n\nThe basic idea is to record the min length of 4 directions, for example:\n```\t\t\t\t\t\t\n            1\n            1\n      1  grid[i][j]  1  1  1  1\n            1\n```\nThe value of grid[i][j] should be 2 (because **grid[i][j]** it self is also considered 1).\n\nThen we iterator the grid twice.\nThe first pass is from left to right, top to bottom so that we can get the the min(left, top) for each element;\nThe second pass is from right to left , bottom to top so that we can get the min(right, bottom) for each element;\n\nThen we can get the min value of 4 direction and find the max.\n\nJava Code:\n```java\npublic int orderOfLargestPlusSign(int N, int[][] mines) {\n        int[][] grid = new int[N][N];\n        for (int i = 0; i < N; i++) {\n            Arrays.fill(grid[i], 1);\n        }\n        for (int[] mine: mines) {\n            grid[mine[0]][mine[1]] = 0;\n        }\n        int[] pre = new int[N];\n        for (int i = 0; i < N; i++) {\n            int count = 0;\n            for (int j = 0; j < N; j++) {\n                if (grid[i][j] != 0) {\n                    grid[i][j] = Math.min(++count, ++pre[j]);\n                } else {\n                    count = 0;\n                    pre[j] = 0;\n                }\n            }\n        }\n        Arrays.fill(pre, 0);\n        int max = 0;\n        for (int i = N - 1; i >= 0; i--) {\n            int count = 0;\n            for (int j = N - 1; j >= 0; j--) {\n                if (grid[i][j] != 0) {\n                    grid[i][j] = Math.min(grid[i][j], Math.min(++count, ++pre[j]));\n                } else {\n                    count = 0;\n                    pre[j] = 0;\n                }\n                max = Math.max(max, grid[i][j]);\n            }\n        }\n        return max;\n    }\n```\n
[]