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

Method dfs

java/0417-pacific-atlantic-water-flow.java:32–46  ·  view source on GitHub ↗
(
        int[][] heights,
        int i,
        int j,
        int prev,
        boolean[][] ocean
    )

Source from the content-addressed store, hash-verified

30 }
31
32 private void dfs(
33 int[][] heights,
34 int i,
35 int j,
36 int prev,
37 boolean[][] ocean
38 ) {
39 if (i < 0 || i >= ocean.length || j < 0 || j >= ocean[0].length) return;
40 if (heights[i][j] < prev || ocean[i][j]) return;
41
42 ocean[i][j] = true;
43 for (int[] d : dir) {
44 dfs(heights, i + d[0], j + d[1], heights[i][j], ocean);
45 }
46 }
47}

Callers 1

pacificAtlanticMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected