Water flows from higher to lower/equal cells. Pacific touches top & left, Atlantic touches bottom & right. Find cells that can reach both oceans.
Key insight: reverse the flow. Start from ocean borders and DFS inward to cells with height >= current. Intersection of both sets = answer.
💡 Pro tip: Understand this problem deeply — don't just memorize the code. Try explaining the approach out loud as if teaching a friend. If you can explain it simply, you truly understand it!
pacificAtlantic(heights)
7