Start with the widest container: left pointer at index , right pointer at index . This gives maximum width.
Compute the area. Then move the pointer pointing to the shorter line inward. Why? Moving the taller line inward can only decrease area (smaller width, same or smaller height).
But moving the shorter line might find a taller line that compensates for the width loss. This greedy strategy guarantees you find the maximum.