← Visualizers
Advanced Two Pointers LeetCode 11

Container With Most Water / visualized

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 wall right wall current area best 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.