Easy DFS solution with self-explainatory variable names
\nclass Solution:\n    def pacificAtlantic(self, heights: List[List[int]]) -> List[List[int]]:\n        ROWS, COLS = len(heights), len(heights[0])\n        paci
```\nclass Solution:\n    def pacificAtlantic(self, heights: List[List[int]]) -> List[List[int]]:\n        ROWS, COLS = len(heights), len(heights[0])\n        pacificSet, atlanticSet = set(), set()\n        \n        def dfs(row, col, visited, prevHeight):\n            if (row not in range(ROWS) or\n                col not in range(COLS) or\n                (row, col) in visited or\n                heights[row][col] < prevHeight\n               ):\n                return\n            \n            visited.add((row, col))\n            dfs(row + 1, col, visited, heights[row][col])\n            dfs(row - 1, col, visited, heights[row][col])\n            dfs(row, col + 1, visited, heights[row][col])\n            dfs(row, col - 1, visited, heights[row][col])        \n        \n        for row in range(ROWS):\n            dfs(row, 0, pacificSet, heights[row][0])\n            dfs(row, COLS - 1, atlanticSet, heights[row][COLS - 1])\n            \n        for col in range(COLS):\n            dfs(0, col, pacificSet, heights[0][col])\n            dfs(ROWS - 1, col, atlanticSet, heights[ROWS - 1][col])\n        \n        return pacificSet & atlanticSet\n    # Time: O(m * n) where m and n are the dimensions of the grid\n    # Space: O(m * n)\n```\n
['Depth-First Search', 'Python']