MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / dfs

Function dfs

javascript/0130-surrounded-regions.js:49–64  ·  view source on GitHub ↗
(board, row, rows, col, cols)

Source from the content-addressed store, hash-verified

47};
48
49const dfs = (board, row, rows, col, cols) => {
50 const isBaseCase = board[row][col] !== 'O';
51 if (isBaseCase) return;
52
53 board[row][col] = '*';
54
55 for (const [_row, _col] of getNeighbors(row, rows, col, cols)) {
56 dfs(
57 board,
58 _row,
59 rows,
60 _col,
61 cols,
62 ); /* Time O(HEIGHT) | Space O(HEIGHT) */
63 }
64};
65
66var getNeighbors = (row, rows, col, cols) =>
67 [

Callers 2

searchRowsFunction · 0.70
searchColsFunction · 0.70

Calls 1

getNeighborsFunction · 0.70

Tested by

no test coverage detected