Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Pacific Atlantic Water Flow

Medium Graphs

An R x C grid gives cell heights. Water flows to neighbouring cells with equal or lower height. The Pacific touches the top and left edges, the Atlantic the bottom and right edges. Print the number of cells from which water can reach both oceans.

Constraints

1 <= R, C <= 200 0 <= height <= 10^5

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.