Maximum Container Area
Pick two walls that hold the most water between them.
The problem
Implement Solution.maxArea(heights). heights[i] is the height of a vertical wall at position i, and every height is non-negative. Choose two walls; together with the ground they form a container whose area is the distance between the walls times the height of the shorter wall. Return the largest area you can get. heights has at least two walls.
Starter code
class Solution:
def maxArea(self, heights: list[int]) -> int:
passPublic examples
heights = [1, 8, 6, 2, 5, 4, 8, 3, 7]gives49heights = [5, 0, 0, 5]gives15heights = [0, 0, 0]gives0
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
