Given an array of heights representing vertical lines, find two lines that, together with the x-axis, hold the most water, and return that maximum area.
Example 1
Explanation: The lines at index 1 (height 8) and index 8 (height 7) form the best container: min(8, 7) * (8 - 1) = 49.
Example 2
Explanation: The minimal valid input — two lines of height 1, one unit apart, hold exactly 1 unit of water.
Why is it never correct to move the taller boundary inward first? Try to justify it without referring to the code.
Code execution is coming soon.