C++ simple
O(n^2)\n\nCalculate the arm length (include center) for each position from 4 directions and the minimum one will be finally in the g[i][j]\ncnt[0]: from left to
O(n^2)\n\nCalculate the arm length (include center) for each position from 4 directions and the minimum one will be finally in the `g[i][j]`\n`cnt[0]`: from left to right\n`cnt[1]`: from right to left\netc...\n```\nclass Solution {\npublic:\n    int orderOfLargestPlusSign(int n, vector<vector<int>>& mines) {\n        int g[n][n], ans = 0;\n        memset(g, 0x7f, sizeof(g));\n        for (auto &m : mines) g[m[0]][m[1]] = 0;\n        for (int i = 0; i < n; i++) {\n            int cnt[4] = {1, 1, 1, 1}; // count of arm length (include center) from 4 direction\n            for (int j = 0; j < n; j++) {\n                int *t[4] = {&g[i][j], &g[i][n - j - 1], &g[j][i], &g[n - j - 1][i]};\n                for (int k = 0; k < 4; k++) {\n                    if (!*t[k]) cnt[k] = 0;\n                    *t[k] = min(*t[k], cnt[k]++);\n                }\n            }\n        }\n        for (auto &r : g) ans = max(ans, *max_element(r, r + n));\n        return ans;\n    }\n};\n```\n\nO(n * mines.size()) (worst O(n^3))\n\ninitialize every position in `g` to maxiumu length it can have under the situation every point in the grid are 1 -> O(n^2)\n\nthen we check the indies in `mines` and set the corresbonding point in grid to zero and update the elements it affects.\n```\nclass Solution {\npublic:\n    int orderOfLargestPlusSign(int n, vector<vector<int>>& mines) {\n        int g[n][n], ans = 0;\n        for (int i = 0; i < n; i++) \n            for (int j = 0; j < n; j++)\n                g[i][j] = min({1 + i, 1 + j, n - i, n - j});\n        for (auto &m : mines) {\n            for (int i = 0; i < n; i++) {\n                g[i][m[1]] = min(g[i][m[1]], abs(m[0] - i));\n                g[m[0]][i] = min(g[m[0]][i], abs(m[1] - i));\n            }\n        }\n        for (auto &r : g) ans = max(ans, *max_element(r, r + n));\n        return ans;\n    }\n};\n```
[]