O47
Pacific Atlantic Water Flow
Problem Statement & Objective
Return a list of grid coordinates where rainwater can flow to both the Pacific and Atlantic oceans.
Function Signature (Python)
pacific_atlantic_water_flow(heights: list[list[int]]) -> list[list[int]]Input & Output Contract
Output Rule:Kesişim hücrelerinin [r, c] listesi.
System Constraints
m == yukseklikler.length, n == yukseklikler[i].length
1 <= m, n <= 200
0 <= yukseklikler[i][j] <= 10^5Example Execution Walkthrough
yukseklikler = [[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]]
cevap: [[0, 4], [1, 3], [1, 4], [2, 2], [3, 0], [3, 1], [4, 0]]Example Test Scenarios (3)
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]]]Expected Output:
[[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]Example 2: Tek Hücre (Her İki Okyanusa Açar)
Input:
[[[1]]]Expected Output:
[[0,0]]Example 3: 2x2
Input:
[[[2,1],[1,2]]]Expected Output:
[[0,0],[0,1],[1,0],[1,1]]