Python easy to understand BFS
python\n\tdef pacificAtlantic(self, heights: List[List[int]]) -> List[List[int]]:\n        m, n = len(heights), len(heights[0])\n        pacific = deque([[0,j] 
```python\n\tdef pacificAtlantic(self, heights: List[List[int]]) -> List[List[int]]:\n        m, n = len(heights), len(heights[0])\n        pacific = deque([[0,j] for j in range(n)] + [[i,0] for i in range(m)])\n        atlantic = deque([[i,n-1] for i in range(m)] + [[m-1, i] for i in range(n)])\n                \n        def bfs(queue):\n            visited = set()\n            while queue:\n                x,y = queue.popleft()\n                visited.add((x,y))\n                for dx,dy in [[1,0],[0,1],[-1,0],[0,-1]]:\n                    if 0 <= x+dx < m and 0 <= y+dy < n:\n                        if (x+dx, y+dy) not in visited:\n                            if heights[x+dx][y+dy] >= heights[x][y]:\n                                queue.append((x+dx, y+dy))\n            return visited\n        \n        p, a = bfs(pacific), bfs(atlantic)\n                        \n        return p.intersection(a)\n```
['Python', 'Python3']