← All problems

Pacific Atlantic Water Flow

Medium graphsdfsbfsmatrix LeetCode ↗
Cells with heights; find cells from which water flows to both oceans (borders).

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(mn), Space O(mn)

Common pitfalls

  • Wrong flow direction (must go uphill in reverse)
  • Exponential per-cell DFS

Your solution

Log in to save your code and track progress.