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

Function dfs

javascript/0329-longest-increasing-path-in-a-matrix.js:30–46  ·  view source on GitHub ↗
(matrix, row, rows, col, cols, ans = 0)

Source from the content-addressed store, hash-verified

28};
29
30var dfs = (matrix, row, rows, col, cols, ans = 0) => {
31 for (const [_row, _col] of getNeighbors(row, rows, col, cols)) {
32 /* Time O(4) */
33 const path = dfs(
34 matrix,
35 _row,
36 rows,
37 _col,
38 cols,
39 ); /* Time O(2^(N + M)) | Space O(HEIGHT) */
40
41 ans = Math.max(ans, path);
42 }
43
44 ans += 1;
45 return ans;
46};
47
48var getNeighbors = (row, rows, col, cols) =>
49 [

Callers 2

longestIncreasingPathFunction · 0.70
searchFunction · 0.70

Calls 2

getNeighborsFunction · 0.70
searchFunction · 0.70

Tested by

no test coverage detected