(board, queue)
| 110 | }; |
| 111 | |
| 112 | var bfs = (board, queue) => { |
| 113 | const [rows, cols] = [board.length, board[0].length]; |
| 114 | |
| 115 | while (!queue.isEmpty()) { |
| 116 | for (let i = queue.size() - 1; 0 <= i; i--) { |
| 117 | /* Time O(WIDTH) */ |
| 118 | const [row, col] = queue.dequeue(); |
| 119 | |
| 120 | const isBaseCase = board[row][col] !== 'O'; |
| 121 | if (isBaseCase) continue; |
| 122 | |
| 123 | board[row][col] = '*'; |
| 124 | |
| 125 | for (const [_row, _col] of getNeighbors(row, rows, col, cols)) { |
| 126 | queue.enqueue([_row, _col]); /* Space O(WIDTH) */ |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | }; |
| 131 | |
| 132 | var searchGrid = (board) => { |
| 133 | const [rows, cols] = [board.length, board[0].length]; |
no test coverage detected