Container With Most Water
mediumFind two lines that form container holding most water
Container With Most Water
Key Insight
Area = min(heights) × width. Move shorter line inward to potentially increase area.
Step 1Setup
Area = min(1,7) × 8 = 8
left
1
08
16
22
35
44
58
63
7right
7
8→converge←
Start with widest container. Heights: 1 and 7.
1 / 5