Lesson 1 of 5
Live algorithm trace
Container with most water
Complete execution1 of 9
The widest pair holds 8 units; the shorter left wall must move.
1
left = 0; right = length - 1; best = 02
area = (right - left) * min(height[left], height[right])3
best = max(best, area)4
move the pointer at the shorter wall5
return bestarea = 8best = 8
An oasis puzzle: vertical walls of different heights. Pick two walls; water fills between them. Area = width × the shorter wall.