Pacific Atlantic Water Flow

Medium

📝 Description

Find cells where water can flow to both Pacific and Atlantic oceans

Input Format

m×n matrix of heights

Output Format

List of coordinates

Constraints

m == matrix.length n == matrix[i].length

🔍 Sample Input

[[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]
            

✅ Sample Output

[[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run