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

Function searchRows

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

Source from the content-addressed store, hash-verified

34 .map(() => new Array(cols).fill(false));
35
36var searchRows = (heights, rows, cols, pacificReachable, atlanticReachable) => {
37 for (let row = 0; row < rows; row++) {
38 /* Time O(ROWS) */
39 const [pacificStart, atlanticStart] = [0, cols - 1];
40
41 dfs(
42 row,
43 pacificStart,
44 rows,
45 cols,
46 pacificReachable,
47 heights,
48 ); /* Space O(ROWS * COLS) */
49 dfs(
50 row,
51 atlanticStart,
52 rows,
53 cols,
54 atlanticReachable,
55 heights,
56 ); /* Space O(ROWS * COLS) */
57 }
58};
59
60var searchCols = (heights, rows, cols, pacificReachable, atlanticReachable) => {
61 for (let col = 0; col < cols; col++) {

Callers 1

searchFunction · 0.70

Calls 1

dfsFunction · 0.70

Tested by

no test coverage detected