Pacific Atlantic Water Flow

Last updated

What is Pacific Atlantic Water Flow?

Given a matrix of heights, find all cells from which water can flow to both the Pacific and Atlantic oceans. You reverse the problem: do BFS inward from each ocean's border, marking all reachable cells, then return cells reachable from both. This problem teaches you that reversing the direction of traversal can turn an exponential problem into a linear one.

Free resources to learn Pacific Atlantic Water Flow

More in stage 14: Graphs

Pacific Atlantic Water Flow: common questions

Can I learn Pacific Atlantic Water Flow in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Pacific Atlantic Water Flow in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this Pacific Atlantic Water Flow tutorial for beginners?

It is lesson 85 of 137 in the free LeetCode roadmap, in stage 14, Graphs. If you are new to LeetCode, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me