C++ Easy & Understandable code with Comments || O(n^2)
Brute Force approach\n- In  the brute approach we can try each cell(r,c) as potential plus center then expand left, right, bottom, top and among then compute mi
**Brute Force approach**\n- In  the brute approach we can try each cell(r,c) as potential plus center then expand left, right, bottom, top and among then compute minimum distance. \n- Brute force approach will be inefficient having T.C. O(n^3)\n\n**Dynamic Programming**\n- In this approach we take a dp matrix.\n- here we count continuos 1s in four directions and store minimum in dp\n\n<hr>\n\n**Please Upvote. Thanks:)**\n\n\n```\nclass Solution {\npublic:\n    void computeOrderOfPlus(vector<vector<int>>& grid, vector<vector<int>>& dp, int n){\n        \n        int leftToRight = 0, topToBottom = 0, rightToBottom = 0, bottomToTop = 0;\n        \n        for(int i=0; i<n; ++i){\n            leftToRight = 0, topToBottom = 0; // reset value becuase we restarting counting for each row\n            for(int j=0; j<n; ++j){\n                // calcualte continuous 1s present left to current cell until zero\n                leftToRight = grid[i][j] ? leftToRight+1 : 0;\n                dp[i][j] = min(dp[i][j], leftToRight);\n                \n                // calcualte continuous 1s present top till current cell until zero\n                topToBottom = grid[j][i] ? topToBottom+1 : 0; // here cell ( j, i ) because we compute top to bottom.\n                dp[j][i] = min(dp[j][i], topToBottom);\n            }\n        }\n        \n        for(int i=0; i<n; ++i){\n            rightToBottom = 0, bottomToTop = 0;\n            for(int j=n-1; j>=0; --j){\n                // calcualte continuous 1s present right to current cell\n                rightToBottom = grid[i][j] ? rightToBottom+1 : 0;\n                dp[i][j] = min(dp[i][j], rightToBottom);\n                \n                // calcualte continuous 1s present bottom till current cell\n                bottomToTop = grid[j][i] ? bottomToTop+1 : 0; // here cell ( j, i ) because we compute bottom to top\n                dp[j][i] = min(dp[j][i], bottomToTop); \n            }\n        }\n    }\n    \n    int orderOfLargestPlusSign(int n, vector<vector<int>>& mines) {\n        vector<vector<int>> grid(n, vector<int>(n, 1));//prefill with 1s\n        vector<vector<int>> dp(n, vector<int>(n, INT_MAX));// initialize with max value so later will update with minimum left, right, top, bottom distance\n        \n        for(auto mine: mines){\n            grid[mine.at(0)][mine.at(1)] = 0; // fill grid with zero\n        }\n        \n        computeOrderOfPlus(grid, dp, n);\n        // fillDP(dp, grid, n);\n        \n        int res = 0;\n        // get the maximum value from dp matrix\n        for(auto row: dp){\n            for(auto ele : row){\n                res = max(res, ele);\n            }\n        }\n        \n        return res;\n    }\n};
['C', 'C++']