The limiting wall

Container With Most Water

Discover what you can safely leave behind.

02/03
The challenge, in plain language +

A row of upright walls stands one unit apart. Each number gives a wall's height. Choose two walls to form the sides of a container; the floor lies between them. Water can rise only as high as the shorter chosen wall. Return the largest cross-sectional area any pair can hold. Use nonnegative finite heights; with fewer than two walls, return 0.

BEFORE THE FIRST HINT · SPOT THE KEY

Which fact makes it possible to eliminate many pairs at once?

This lesson uses 2D: exact positions, widths and comparisons are easier to read in one plane.