Pacific Atlantic Water Flow
Graphs · reverse traversal · Search backwards from both destinations · Stretch · about 32 min
Why it matters
Reversing a search direction can turn many expensive searches into two simple ones.
How it connects
Instead of asking each cell whether it can reach two oceans, begin at the oceans and reverse the question.
Try first
From an ocean edge, which neighbouring heights can reach back to it?
Interview cue
Reverse traversal turns “every cell reaches two oceans” into two shared reachability searches.