Skip to content

#11 - Container With Most Water

MediumTwo Pointers
Open on LeetCode

Given an integer array height of length n, where each element represents the height of a vertical line drawn at index i, find two lines that together with the x-axis form a container that holds the most water. Return the maximum amount of water the container can store. The container may not be slanted.

InputOutput
height = [1,8,6,2,5,4,8,3,7]49
height = [1,1]1
height = [4,3,2,1,4]16

Released under the MIT License.