Given an array of integers representing the heights of vertical containers, calculate the maximum amount of water that can be contained between them. The water can only be trapped if there are taller containers on both sides. The width of each container is 1.
Example 1:
Input: heights = [1, 8, 6, 2, 5, 4, 8, 3, 7]
Output: 49
The maximum water is trapped between the containers at indices 1 and 8, which is (8-1) * (8-1) = 49.
Example 2:
Input: heights = [1, 1]
Output: 1
The only possible water trapped is between the two containers, which gives a volume of 1.
2 <= heights.length <= 10^50 <= heights[i] <= 10^4