Easiest c++ solution | DP O(n^2)
\nclass Solution {\npublic:\n    int orderOfLargestPlusSign(int n, vector<vector<int>>& mines) {\n        int ans=0;\n\t\t// just walk from every direction one 
```\nclass Solution {\npublic:\n    int orderOfLargestPlusSign(int n, vector<vector<int>>& mines) {\n        int ans=0;\n\t\t// just walk from every direction one by one to each cell and store the min. contiguous valid 1\'s length of every direction\n        vector<vector<int>> dp(n,vector<int>(n,INT_MAX));\n        vector<vector<int>> mat(n,vector<int>(n,1));\n        for(int i=0; i<mines.size(); i++) mat[mines[i][0]][mines[i][1]]=0;\n        for(int i=0; i<n; i++) {\n             int c=0;\n             for(int j=0; j<n; j++) {    // walk right to each pos \n                   mat[i][j]?c++:c=0; \n                   dp[i][j]=min(dp[i][j],c);\n             }\n        }\n        for(int i=0; i<n; i++) {\n            int c=0;\n            for(int j=n-1; j>=0; j--) {   // walk left to each pos\n                   mat[i][j]?c++:c=0; \n                   dp[i][j]=min(dp[i][j],c);\n            }\n        }\n        for(int i=0; i<n; i++) {\n            int c=0;\n            for(int j=0; j<n; j++) {\n                  mat[j][i]?c++:c=0;     // walk down to each pos\n                  dp[j][i]=min(dp[j][i],c);\n            }\n        }\n        for(int i=0; i<n; i++) {\n            int c=0;\n            for(int j=n-1; j>=0; j--) {  // walk up to each pos \n                  mat[j][i]?c++:c=0;\n                  dp[j][i]=min(c,dp[j][i]);\n            }\n        }\n        for(int i=0; i<n; i++) {\n            for(int j=0; j<n; j++) {\n                ans=max(ans,dp[i][j]);  \n            }\n        }\n        return ans;\n    }\n};\n```
['Math', 'Dynamic Programming', 'C']