My Simple O(N^2) Time and O(N^2) Space Accepted Solution 150ms
Created 4 matrices for storing largest streak of ones on left, right top and bottom. Finally, take the min of all four directions. \nThe maximum of these minimu
Created 4 matrices for storing largest streak of ones on left, right top and bottom. Finally, take the min of all four directions. \nThe maximum of these minimums is the answer.\n```\nclass Solution {\n    public int orderOfLargestPlusSign(int N, int[][] mines) {\n        int[][] matrix = new int[N][N];\n        for(int[] mat:matrix){\n            Arrays.fill(mat, 1);\n        }\n        for(int[] mine: mines){\n            matrix[mine[0]][mine[1]] = 0;\n        }\n        int ans = 0;\n        if(mines.length<N*N) ans = 1;\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(matrix[i][j]==1){ \n                    top[i][j] = (i-1>=0)?top[i-1][j]+1:1;\n                    left[i][j] = (j-1>=0)?left[i][j-1]+1:1;\n                }\n            }    \n        }\n        \n        \n        for(int i=N-1;i>=0;i--){\n            for(int j=N-1;j>=0;j--){\n                if(matrix[i][j]==1){ \n                    bottom[i][j] = (i+1<N)?bottom[i+1][j]+1:1;\n                    right[i][j] = (j+1<N)?right[i][j+1]+1:1;\n                }\n                \n                ans = Math.max(ans, Math.min(Math.min(left[i][j],bottom[i][j]), Math.min(right[i][j],top[i][j])));\n            }    \n        }\n        return ans;\n    }\n}\n```
[]