← problems
#11

Container With Most Water

MediumTwo Pointers

You are given an integer array height of length n. There are n vertical lines where line i has endpoints (i, 0) and (i, height[i]).

Find two lines that together with the x-axis form a container holding the most water, and return that maximum area.

Example

height = [1, 8, 6, 2, 5, 4, 8, 3, 7]  => 49
Implement
function MaxArea(height: int[]) -> int

Found a bug? Or annoyed about something in the language? Tell us.

loading editor…