Intersting solution, Worth your time
you can check out my github repository where i am uploading famous interview questions topic wise with solutions.\nlink-- https://github.com/Abhaydutt2003/DataS
you can check out my github repository where i am uploading famous interview questions topic wise with solutions.\nlink-- https://github.com/Abhaydutt2003/DataStructureAndAlgoPractice \nkindly upvote if you like my solution. you can ask doubts below.\xAF\n    \n\n# Code\n```\nclass Solution {\n    public int orderOfLargestPlusSign(int n, int[][] mines) {\n        return util1(n,mines);\n    }\n    public int util1(int n, int mines[][]) {\n        int matrix[][] = new int[n][n];\n        // reverse the behaviour of 0 and 1\n        for (int i = 0; i < mines.length; i++) {\n            matrix[mines[i][0]][mines[i][1]] = 1;\n        }\n        int[][][] fuck = new int[n][n][4];\n        // {up,left,bottom,right}\n        // fill fuck for left and up\n        for (int i = 0; i < matrix.length; i++) {\n            for (int j = 0; j < matrix[0].length; j++) {\n                if (matrix[i][j] == 1) {\n                    // do nothing\n                    continue;\n                } else {\n                    if (i == 0 && j == 0) {\n                        fuck[i][j][0] = 1;\n                        fuck[i][j][1] = 1;\n                    } else if (i == 0) {\n                        fuck[i][j][0] = 1;\n                        fuck[i][j][1] = fuck[i][j - 1][1] + 1;\n                    } else if (j == 0) {\n                        fuck[i][j][1] = 1;\n                        fuck[i][j][0] = fuck[i - 1][j][0] + 1;\n                    } else {\n                        fuck[i][j][0] = fuck[i - 1][j][0] + 1;\n                        fuck[i][j][1] = fuck[i][j - 1][1] + 1;\n                    }\n                }\n            }\n        }\n        // fill fuck for bottom and right\n        for (int i = matrix.length - 1; i >= 0; i--) {\n            for (int j = matrix[i].length - 1; j >= 0; j--) {\n                if (matrix[i][j] == 1) {\n                    // do nothing\n                    continue;\n                } else {\n                    if (i == matrix.length - 1 && j == matrix.length - 1) {\n                        fuck[i][j][2] = 1;\n                        fuck[i][j][3] = 1;\n                    } else if (i == matrix.length - 1) {\n                        fuck[i][j][2] = 1;\n                        fuck[i][j][3] = fuck[i][j + 1][3] + 1;\n                    } else if (j == matrix.length - 1) {\n                        fuck[i][j][3] = 1;\n                        fuck[i][j][2] = fuck[i + 1][j][2] + 1;\n                    } else {\n                        fuck[i][j][2] = fuck[i + 1][j][2] + 1;\n                        fuck[i][j][3] = fuck[i][j + 1][3] + 1;\n                    }\n                }\n            }\n        }\n        // fuck is filled,now get the answer\n        int ans = 0;\n        for (int i = 0; i < fuck.length; i++) {\n            for (int j = 0; j < fuck[i].length; j++) {\n                if (matrix[i][j] == 1) {\n                    // do nothing\n                    continue;\n                } else {\n                    if (i == 0 || j == 0 || i == matrix.length - 1 || j == matrix[0].length - 1) {\n                        ans = Math.max(ans, 1);\n                    } else {\n                        int up = fuck[i][j][0];\n                        int left = fuck[i][j][1];\n                        int bottom = fuck[i][j][2];\n                        int right = fuck[i][j][3];\n                        int smallAns = Math.min(up, Math.min(left, Math.min(bottom, right)));\n                        ans = Math.max(smallAns, ans);\n                    }\n                }\n            }\n        }\n        return ans;\n    }\n}\n```
['Dynamic Programming', 'Matrix', 'Java']