My Java Solution using DFS
\nclass Solution {\n    public List<List<Integer>> pacificAtlantic(int[][] matrix) {\n        List<List<Integer>> result = new ArrayList<>();\n        int row =
```\nclass Solution {\n    public List<List<Integer>> pacificAtlantic(int[][] matrix) {\n        List<List<Integer>> result = new ArrayList<>();\n        int row = matrix.length;\n        if (row == 0)\n            return result;\n        int col = matrix[0].length;\n        boolean [][] pacific = new boolean [row][col];\n        boolean [][] atlantic = new boolean [row][col];\n        // top bottom\n        for (int i=0; i<col; i++) {\n            dfs(matrix, 0, i, matrix[0][i], pacific);\n            dfs(matrix, row-1, i, matrix[row-1][i], atlantic);\n        }\n        // left right\n        for (int i=0; i<row; i++) {\n            dfs(matrix, i, 0, matrix[i][0], pacific);\n            dfs(matrix, i, col-1, matrix[i][col-1], atlantic);\n        }\n        for (int i=0; i<row; i++) {\n            for (int j=0; j<col; j++) {\n                if (pacific[i][j] && atlantic[i][j]) {\n                    List<Integer> currentResult = new ArrayList<>();\n                    currentResult.add(i);\n                    currentResult.add(j);\n                    result.add(currentResult);\n                }\n            }\n        }\n        return result;\n    }\n    \n    public void dfs(int [][] matrix, int i, int j, int preHeight, boolean [][] ocean) {\n        if (i < 0 || j < 0 || i >= matrix.length || j >= matrix[0].length || preHeight > matrix[i][j] || ocean[i][j])\n            return;\n        ocean[i][j] = true;\n        dfs(matrix, i+1, j, matrix[i][j], ocean);\n        dfs(matrix, i-1, j, matrix[i][j], ocean);\n        dfs(matrix, i, j+1, matrix[i][j], ocean);\n        dfs(matrix, i, j-1, matrix[i][j], ocean);\n    }\n}\n```
['Depth-First Search', 'Recursion', 'Java']