(rooms, row, col)
| 18 | }; |
| 19 | |
| 20 | const dfs = (rooms, row, col) => { |
| 21 | const [rows, cols] = [rooms.length, rooms[0].length]; |
| 22 | |
| 23 | for (const [_row, _col] of getNeighbors(row, rows, col, cols)) { |
| 24 | const isPreviousDistanceGreater = |
| 25 | rooms[_row][_col] <= rooms[row][col] + 1; |
| 26 | if (isPreviousDistanceGreater) continue; |
| 27 | |
| 28 | rooms[_row][_col] = rooms[row][col] + 1; |
| 29 | |
| 30 | dfs(rooms, _row, _col); |
| 31 | } |
| 32 | }; |
| 33 | |
| 34 | var getNeighbors = (row, rows, col, cols) => |
| 35 | [ |
no test coverage detected