#K42367. Maximum Water Container
Maximum Water Container
Maximum Water Container
Given a list of non-negative integers representing the heights of vertical lines on a 2D plane, your task is to find two lines such that, together with the x-axis, they form a container that holds the maximum amount of water. The container's area is computed using the formula: \(A = (j - i) \times \min(height[i], height[j])\), where \(i\) and \(j\) are the indices of the two lines with \(0 \leq i < j < N\).
This problem challenges you to efficiently determine the maximum water that can be trapped between any two of these vertical lines.
inputFormat
The first line contains an integer \(N\), the number of vertical lines. The second line contains \(N\) space-separated non-negative integers representing the heights of the lines.
outputFormat
Output a single integer representing the maximum area of water the container can hold.
## sample9
1 8 6 2 5 4 8 3 7
49
</p>