Water can flow from one cell to another if the adjacent cell’s height is less than or equal to the current cell's height. Adjacent cells refers to cells directly north, south, west, and east of the a cell.
Return a list of all cells from which water can flow to both oceans in sorted order, based on their position when traversing the matrix from the top-left to the bottom-right
Examples
Input: matrix = [[1,2,3,1],[4,3,3,4],[5,2,4,3],[5,2,1,5],[1,5,1,3]]
Output: [[0,2],[0,3],[1,0],[1,1],[1,2],[1,3],[2,0],[2,2],[3,0],[4,0],[4,1]]
Explanation: The listed cells are capable of reaching both oceans. For instance, the cell at (row 0, column 2) can flow directly to the top left ocean, and then from (row 0, column 2) it can reach the bottom right ocean through (row 0, column 3).
Input: matrix = [[1]]
Output: [[0,0]]
Explanation: The only cell can flow to both oceans.
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
Output: [[0,2],[1,2],[2,0],[2,1],[2,2]]
Explanation: The listed cells are capable of reaching both oceans