(grid, row, col)
| 15 | } |
| 16 | |
| 17 | function search(grid, row, col) { |
| 18 | const stack = [[row, col]]; |
| 19 | |
| 20 | while (stack.length > 0) { |
| 21 | const currentPosition = stack.pop(); |
| 22 | const [currentRow, currentCol] = currentPosition; |
| 23 | grid[currentRow][currentCol] = "0"; |
| 24 | const neighbors = getNeighbors(grid, currentRow, currentCol); |
| 25 | for (const neighbor of neighbors) { |
| 26 | stack.push(neighbor); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | function getNeighbors(grid, row, col) { |
| 32 | const neighbors = []; |
no test coverage detected