(rooms, queue)
| 80 | }; |
| 81 | |
| 82 | const checkNeighbors = (rooms, queue) => { |
| 83 | const [rows, cols] = [rooms.length, rooms[0].length]; |
| 84 | const [row, col] = queue.dequeue(); |
| 85 | |
| 86 | for (const [_row, _col] of getNeighbors(row, rows, col, cols)) { |
| 87 | const isINF = rooms[_row][_col] === 2147483647; /* (2 ** 31) - 1 */ |
| 88 | if (!isINF) continue; |
| 89 | |
| 90 | rooms[_row][_col] = rooms[row][col] + 1; |
| 91 | queue.enqueue([_row, _col]); |
| 92 | } |
| 93 | }; |
| 94 | |
| 95 | var getNeighbors = (row, rows, col, cols) => |
| 96 | [ |