Pattern Recognition Drill
Medium Two Pointers
The Problem
Given n vertical lines, find two that form a container holding the most water.
What approach would you use?
Think about it before scrolling down.
Start at widest. Move the shorter line inward (can't do better keeping it). O(n).
Same logic. Moving the taller line can only decrease width without guaranteeing height increase.
Common Trap
Don't try all O(n²) pairs. The greedy proof: moving the taller side can never improve area.