javascript brute force and dp
reference:\nhttps://leetcode.com/problems/largest-plus-sign/discuss/113350/C%2B%2B-simple-brute-force-easy-to-understand-with-detailed-explanation\nhttps://leet
reference:\nhttps://leetcode.com/problems/largest-plus-sign/discuss/113350/C%2B%2B-simple-brute-force-easy-to-understand-with-detailed-explanation\nhttps://leetcode.com/problems/largest-plus-sign/discuss/113314/JavaC%2B%2BPython-O(N2)-solution-using-only-one-grid-matrix\n```\n////////////////////////////// Brute force 492ms --- 50% fast //////////////////////////////\nconst orderOfLargestPlusSign = (N, mines) => {\n    let res = 0;\n    let data = initialize2DArrayNew(N, N);\n    for (const m of mines) {\n        data[m[0]][m[1]] = 0;\n    }\n    for (let i = 0; i < N; i++) {\n        for (let j = 0; j < N; j++) {\n            let step = 0;\n            while (ok(data, N, i, j, step)) {\n                step++;\n            }\n            res = Math.max(res, step);\n        }\n    }\n    return res;\n};\n\nconst ok = (data, N, x, y, step) => {\n    if (x - step < 0 || y - step < 0 || x + step >= N || y + step >= N) return false;\n    return data[x - step][y] && data[x + step][y] && data[x][y - step] && data[x][y + step];\n};\n\nconst initialize2DArrayNew = (m, n) => {\n    let data = [];\n    for (let i = 0; i < m; i++) {\n        let tmp = new Array(n).fill(1);\n        data.push(tmp);\n    }\n    return data;\n};\n\n////////////////////////////// DP 180ms --- 100% fast //////////////////////////////\nconst orderOfLargestPlusSign = (N, mines) => {\n    let res = 0;\n    let dp = [];\n    for (let i = 0; i < N; i++) {\n        dp.push(new Array(N).fill(N));\n    }\n    for (const m of mines) {\n        dp[m[0]][m[1]] = 0;\n    }\n    for (let i = 0; i < N; i++) {\n        let l = r = u = d = 0;\n        for (let j = 0, k = N - 1; j < N; j++, k--) {\n            dp[i][j] = Math.min(dp[i][j], l = (dp[i][j] == 0 ? 0 : l + 1));\n            dp[j][i] = Math.min(dp[j][i], u = (dp[j][i] == 0 ? 0 : u + 1));\n            dp[i][k] = Math.min(dp[i][k], r = (dp[i][k] == 0 ? 0 : r + 1));\n            dp[k][i] = Math.min(dp[k][i], d = (dp[k][i] == 0 ? 0 : d + 1));\n        }\n    }\n    for (let i = 0; i < N; i++) {\n        for (let j = 0; j < N; j++) {\n            res = Math.max(res, dp[i][j]);\n        }\n    }\n    return res;\n};\n\n////////////////////////////// DP another version 188ms --- 100% fast //////////////////////////////\nconst orderOfLargestPlusSign = (N, mines) => {\n    let res = 0;\n    let dp = [];\n    for (let i = 0; i < N; i++) {\n        dp.push(new Array(N).fill(N));\n    }\n    for (const m of mines) {\n        dp[m[0]][m[1]] = 0;\n    }\n    for (let i = 0; i < N; i++) {\n        let l = r = u = d = 0;\n        for (let j = 0, k = N - 1; j < N; j++, k--) {\n            dp[i][j] = Math.min(dp[i][j], l = (dp[i][j] == 0 ? 0 : l + 1));\n            dp[j][i] = Math.min(dp[j][i], u = (dp[j][i] == 0 ? 0 : u + 1));\n            dp[i][k] = Math.min(dp[i][k], r = (dp[i][k] == 0 ? 0 : r + 1));\n            dp[k][i] = Math.min(dp[k][i], d = (dp[k][i] == 0 ? 0 : d + 1));\n        }\n    }\n    for (let k = 0; k < N * N; ++k) res = Math.max(res, dp[Math.floor(k / N)][k % N]);  // difference\n    return res;\n};\n```
[]