Junior — Senior
Finding the container that holds the maximum volume of liquid
livecode
Task condition
Given an array of integers heights of length n. On the coordinate plane, n vertical line segments are constructed, where the i-th segment connects the points (i, 0) and (i, heights[i]). It is required to select two such lines that, together with the x-axis, form a container capable of holding the maximum amount of water. Return the maximum volume of water that this container can contain. Note that the container cannot be tilted.