Method
dfs
(
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 | } |
Tested by
no test coverage detected