🔥 Javascript Solution - Detailed Annotated
\n/**\n * @param {number} n\n * @param {number[][]} mines\n * @return {number}\n */\nvar orderOfLargestPlusSign = function(n, mines) {\n    // create n * n as a
```\n/**\n * @param {number} n\n * @param {number[][]} mines\n * @return {number}\n */\nvar orderOfLargestPlusSign = function(n, mines) {\n    // create n * n as a table, and each grid fill the maximum number\n    const t = new Array(n).fill(0).map(() => new Array(n).fill(n));\n\n    // insert `0` to the grid in table according the position in mines\n    mines.forEach(a => t[a[0]][a[1]] = 0);\n\n    // loop each rows and cols\n    // - for rows: calculate non-zero grid from left to right\n    // - for cols: calculate non-zero grid from top to bottom\n    // - when the loop is completed, all of non-zero values will be calculated by four directions\n    // - and these grids value will be updated by comparing. then we can obtain the minimum value of the four directions caculation, which is the maximum of the grid\n    for (let i = 0; i < n; i++) {\n        // save the maximum value of non-zeros with for directions\n        let [l, r, u, d] = [0, 0, 0, 0];\n\n        // l: left,  loop row i from left to right\n        // r: right, loop row i from right to left\n        // u: up,    loop col i from top to bottom\n        // d: down,  loop col i from bottom to top\n        for (let j = 0, k = n - 1; j < n; j++, k--) {\n            // if the value is `0`, then set variable to `0`, and indicates it\'s broken\n            l = t[i][j] && l + 1;\n            r = t[i][k] && r + 1;\n            u = t[j][i] && u + 1;\n            d = t[k][i] && d + 1;\n\n            // if current value is less than origin value\n            // one possibility: the origin value is default\n            // another possibility: the length of non-zero in a centain direction is langer than in the current direction, which the minimum value we need\n            if (l < t[i][j]) t[i][j] = l;\n            if (r < t[i][k]) t[i][k] = r;\n            if (u < t[j][i]) t[j][i] = u;\n            if (d < t[k][i]) t[k][i] = d;\n        }\n    }\n\n    // return maximum value be saved by all cells\n    return Math.max(...t.map(v => Math.max(...v)));\n}\n```
['JavaScript']