You are given a list height of n numbers. Imagine n vertical walls in a row. Wall i stands at position i and is height[i] tall.
Pick any two walls. With the ground, they make a tank. The water can rise only to the height of the shorter wall, and you cannot tilt the tank.
The water a tank holds is (distance between the two walls) x (height of the shorter wall). Return the largest amount of water any tank can hold.
Examples
Example 1:
Input: height = [5,2,3,1,5]
Output: 20
Explanation: Use the first and last walls. Distance = 4, shorter height = 5. Water = 4 x 5 = 20.
Example 2:
Input: height = [2,5,4,7,3]
Output: 10
Explanation: Use the walls of height 5 and 7. Distance = 2, shorter height = 5. Water = 2 x 5 = 10.
Example 3:
Input: height = [6,1]
Output: 1
Explanation: There are only two walls. Distance = 1, shorter height = 1. Water = 1.