JS solution 100% time 100% space
\nvar highestPeak = function(w) {\n    const m = w.length\n    const n = w[0].length\n    let q = []\n    for(let mi=0; mi<m; mi++){\n        for(let ni=0; ni<n
```\nvar highestPeak = function(w) {\n    const m = w.length\n    const n = w[0].length\n    let q = []\n    for(let mi=0; mi<m; mi++){\n        for(let ni=0; ni<n; ni++){\n            if(w[mi][ni]) q.push([mi, ni])\n        }\n    }\n    \n    const pos = [[-1, 0], [1, 0], [0, -1], [0, 1]]\n    function getCells([mi, ni]){\n        return pos.map(([ud,lr])=>[mi+ud, ni+lr])\n            .filter(([mj, nj])=>(mj>=0 && mj<m && nj>=0 && nj<n) && !w[mj][nj])\n    }\n    \n    const h = Array(m).fill(0).map(()=>Array(n).fill(0))\n    \n    let i = 0 // reduce time for q.shift\n    while(i<q.length){\n        const cell = q[i++]\n        const cells = getCells(cell)\n        const newHeight = h[cell[0]][cell[1]]+1 // reduce time for array lookup\n        cells\n            .filter(([mj, nj])=>!h[mj][nj])\n            .forEach(c=>{\n                h[c[0]][c[1]]=newHeight\n                q.push(c)\n        })\n    }\n    \n    return h\n    \n};\n```
['JavaScript']