heights[r][c] is the height of a cell. Water flows from a cell to a neighbour (up, down, left, right) that is at the same height or lower. The Pacific ocean touches the top and left edges, the Atlantic touches the bottom and right edges. Return, as [row, col] pairs sorted by row and then column, all cells from which water can reach both oceans.
For [[1, 2], [2, 1]] the answer is [[0, 1], [1, 0]].
Example 1
Input:
pacific_atlantic([[1, 2], [2, 1]])
Output:
[[0, 1], [1, 0]]
Example 2
Input:
pacific_atlantic([[1]])
Output:
[[0, 0]]
0 <= rows, cols <= 2000 <= heights[r][c] <= 10**5No results yet
Run your code to check it against the examples, or submit to run every test.