JAVA || Easy Solution Using DFS || 91% Faster Code
\tPLEASE UPVOTE IF YOU LIKE.\n\nclass Solution {\n    public List<List<Integer>> pacificAtlantic(int[][] heights) {\n        int rows = heights.length, cols = h
\tPLEASE UPVOTE IF YOU LIKE.\n```\nclass Solution {\n    public List<List<Integer>> pacificAtlantic(int[][] heights) {\n        int rows = heights.length, cols = heights[0].length;\n        boolean[][] pac = new boolean[rows][cols];\n        boolean[][] atl = new boolean[rows][cols];\n        \n        for (int col = 0; col< cols; col++){\n            dfs(0, col, rows, cols, pac, heights[0][col], heights);\n            dfs(rows-1, col,rows, cols, atl, heights[rows-1][col], heights);\n        }\n        for (int row = 0; row<rows; row++){\n            dfs(row, 0,rows, cols, pac, heights[row][0], heights);\n            dfs(row, cols-1,rows, cols, atl, heights[row][cols-1], heights);\n        }\n        List<List<Integer>> result = new ArrayList<List<Integer>>();\n        for (int i = 0; i < rows; i++)\n            for (int j = 0; j < cols; j++){\n                if (pac[i][j] && atl[i][j])\n                    result.add(Arrays.asList(i,j));\n            }\n        return result;\n    }\n    private void dfs(int row, int col, int rows, int cols, boolean[][] visited, int prevHeight, int[][] heights){\n        if (row < 0 || row >= rows || col < 0 || col >= cols || visited[row][col] || prevHeight > heights[row][col])\n            return;\n        visited[row][col]= true;\n        dfs(row+1, col, rows, cols, visited, heights[row][col], heights);\n        dfs(row-1, col, rows, cols, visited, heights[row][col], heights);\n        dfs(row, col+1, rows, cols, visited, heights[row][col], heights);\n        dfs(row, col-1, rows, cols, visited, heights[row][col], heights);\n        \n    }\n}\n```
['Depth-First Search', 'Java']