Widest Water Container
heights[i] is the height of a vertical wall at position . Choose two walls; the water they hold is
Return the maximum possible area.
Requirements
- Run in time.
Examples
EXAMPLE WALKTHROUGHclassic
A guided view of the published example, not a trace of your code.
INPUT
[[1,8,6,2,5,4,8,3,7]]TASKwidest_water_container()
EXPECTED OUTPUT
49Start with the input values shown in this example.
Example 1 of 3
Input: heights = [1,8,6,2,5,4,8,3,7]
Output: 49
Explanation: classic
Input: heights = [1,1]
Output: 1
Explanation: two walls
Input: heights = [4,3,2,1,4]
Output: 16
Explanation: outer walls best
Hint 1
Start with the widest pair and move the shorter wall inward. Why can moving the taller wall never help?