Container with most water
Choose two heights that hold the most water: the shorter height limits depth and their distance gives width.
Remember: Measure area; move the shorter side.
Example: [3,1,3] → min(3,3) × 2 = 6.
Time: O(n). Auxiliary space: O(1).
Formula: area = min(h[left], h[right]) × (right − left)
Heights must be nonnegative. Width is the distance between zero-based indices.
Complexities describe the underlying algorithm; tutorial snapshots and rendering can use additional resources.
The interactive workspace loads here when JavaScript is available. You can still browse the learning notes and links above without it.