Python solution using bfs and sets.
\nclass Solution(object):\n    def pacificAtlantic(self, matrix):\n        if not matrix: return []\n        m, n = len(matrix), len(matrix[0])\n        def bfs
```\nclass Solution(object):\n    def pacificAtlantic(self, matrix):\n        if not matrix: return []\n        m, n = len(matrix), len(matrix[0])\n        def bfs(reachable_ocean):\n            q = collections.deque(reachable_ocean)\n            while q:\n                (i, j) = q.popleft()\n                for (di, dj) in [(0,1), (0, -1), (1, 0), (-1, 0)]:\n                    if 0 <= di+i < m and 0 <= dj+j < n and (di+i, dj+j) not in reachable_ocean \\\n                        and matrix[di+i][dj+j] >= matrix[i][j]:\n                        q.append( (di+i,dj+j) )\n                        reachable_ocean.add( (di+i, dj+j) )\n            return reachable_ocean         \n        pacific  =set ( [ (i, 0) for i in range(m)]   + [(0, j) for j  in range(1, n)]) \n        atlantic =set ( [ (i, n-1) for i in range(m)] + [(m-1, j) for j in range(n-1)]) \n        return list( bfs(pacific) & bfs(atlantic) )\n```
[]