Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

Walls of Water

Learn
Play
Prove
Lesson 1 of 5

Live algorithm trace

Container with most water

Complete execution
1 of 9

The widest pair holds 8 units; the shorter left wall must move.

1left = 0; right = length - 1; best = 0
2area = (right - left) * min(height[left], height[right])
3best = max(best, area)
4move the pointer at the shorter wall
5return best
area = 8best = 8

An oasis puzzle: vertical walls of different heights. Pick two walls; water fills between them. Area = width × the shorter wall.

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead