601. The Widest Container
n vertical lines stand on a number line, the ith at position i with
height h[i]. Choosing two lines forms a container whose water is limited by
the SHORTER line and by the distance between them.
Print the most water any pair can hold.
Checking every pair is quadratic. Start with the widest possible pair, one pointer at each end, and move the pointer at the SHORTER line inward.
Why that move is safe is the whole problem: the shorter line caps this pair's area, and every remaining pair using it is narrower, so none of them can beat what was just measured. Discarding it loses nothing. Moving the taller one instead would discard pairs that might still be better.
Constraints - `2 ≤ n ≤ 100000` - `0 ≤ h[i] ≤ 100000`
Input
The first line contains an integer n.
The second line contains n space-separated heights.
Output
Print one integer: the greatest area any pair of lines can hold.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.