Skip to content
Veltoryx Technologies
ProProblem 23● MediumLeetCode #11 ↗3 min readUpdated 30 October 2026

Container With Most Water

Pick the two lines that hold the most water by starting with the widest container and always moving the shorter wall.

01The problem

height[i] is a vertical line at position i. Pick two lines that, with the x-axis, hold the most water. The water level is the shorter line, and the width is the distance between them. Return the maximum area. You can't tilt the container.

InputOutputWhy
[1, 8, 6, 2, 5, 4, 8, 3, 7]49lines 8 and 7, 7 apart
[1, 1]1

Constraints: 2 to 100,000 lines, heights 0 to 10,000.

Loading the rest of the lesson…