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

Function searchCols

javascript/0417-pacific-atlantic-water-flow.js:60–82  ·  view source on GitHub ↗
(heights, rows, cols, pacificReachable, atlanticReachable)

Source from the content-addressed store, hash-verified

58};
59
60var searchCols = (heights, rows, cols, pacificReachable, atlanticReachable) => {
61 for (let col = 0; col < cols; col++) {
62 /* Time O(COLS) */
63 const [pacificStart, atlanticStart] = [0, rows - 1];
64
65 dfs(
66 pacificStart,
67 col,
68 rows,
69 cols,
70 pacificReachable,
71 heights,
72 ); /* Space O(ROWS * COLS) */
73 dfs(
74 atlanticStart,
75 col,
76 rows,
77 cols,
78 atlanticReachable,
79 heights,
80 ); /* Space O(ROWS * COLS) */
81 }
82};
83
84const dfs = (row, col, rows, cols, isReachable, heights) => {
85 isReachable[row][col] = true;

Callers 1

searchFunction · 0.70

Calls 1

dfsFunction · 0.70

Tested by

no test coverage detected