Pacific Atlantic Water Flow
Return a list of grid coordinates where water can flow to both the Pacific and Atlantic oceans.

30:00

Pacific Atlantic Water Flow
medium
Topics
Companies

Return a list of grid coordinates where water can flow to both the Pacific and Atlantic oceans.

Example 1:
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]]
Output: [[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]
Constraints:
  • m==heights.lengthm == \text{heights.length}

  • n==heights[r].lengthn == \text{heights}[r].\text{length}

  • 1m,n2001 \leq m, n \leq 200

  • 0heights[r][c]1050 \leq \text{heights}[r][c] \leq 10^5

Input
arr =[[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]]

Start

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

Variables
No variables to display
DepthFunction Call
Stack empty
0/34