Maximize the water trapped between two vertical lines. Start wide — left
and right at the ends — and always move the shorter wall inward:
moving the taller one can only ever shrink the area.
Execution
idle
Press Run to begin.
0 / 0
Speed
Java · running line
left wallright wallcurrent areabest so far
O(n) time · O(1) space · width shrinks every step, so the only way area can grow is a taller limiting wall — hence move the shorter one.