Problem
You are given a list height where height[i] is the height of a vertical wall at position i. Pick two walls; together with the ground they hold water up to the shorter wall. The amount of water is min(height[i], height[j]) * (j - i). Return the most water any pair can hold.
Example 1
- Input
- height = [1, 8, 6, 2, 5, 4, 8, 3, 7]
- Output
- 49
- Why
- walls at 1 and 8: min(8, 7) * 7
Example 2
- Input
- height = [1, 1]
- Output
- 1
Example 3
- Input
- height = [4, 3, 2, 1, 4]
- Output
- 16
Constraints
2 <= height.length <= 10^50 <= height[i] <= 10^4