← All problems

Container With Most Water

medium

You're given an array height where height[i] is the height of a vertical line at position i. Choose two lines that, together with the x-axis, form a container holding the most water. Return the maximum amount of water it can hold.

Example

Input: height = [1, 8, 6, 2, 5, 4, 8, 3, 7]
Output: 49
Loading...