https://leetcode-cn.com/problems/pacific-atlantic-water-flow/
思路是从海洋开始逆流 如果可以逆流到 就标记为1 然后检查两个海洋都可以逆流到的区域
DFS
public List<List<Integer>> pacificAtlantic(int[][] matrix) {
if (matrix.length == 0 || matrix[0].length == 0) {
return new ArrayList<>();
}
int m = matrix.length;
int n = matrix[0].length;
int[][] pacific = new int[m][n];
int[][] atlantic = new int[m][n];
//从海洋边界开始
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (i == 0 || j == 0) {
dfs(matrix, pacific, i, j, matrix[i][j]);
}
if (i == m - 1 || j == n - 1) {
dfs(matrix, atlantic, i, j