Search⌘ K
AI Features

Pacific Atlantic Water Flow

Explore how to determine cells in a matrix where water can flow to both the Pacific and Atlantic oceans by analyzing heights and applying depth-first search. Learn to implement an efficient O(m·n) solution for this common interview problem.

Statement

Imagine an island with a rectangular shape that touches both the Pacific and Atlantic oceans. The northern and western sides meet the Pacific, while the southern and eastern sides touch the Atlantic. This ...