ntree.aiContainer With Most Water
Container With Most Water
mediumsolvedattempted
You are given an integer array lines, where each element is the height of a vertical line standing at that index.
Two lines and the axis between them form a container.
Find the two lines that form the largest container and return its area.
Example 1:
012345
Input: lines = [2, 9, 4, 1, 7, 3]
Output: 21
Explanation: the lines with heights 9 and 7 form the container with an area of 21 (7 * 3).
Example 2:
012345678
Input: lines = [1, 8, 6, 2, 5, 4, 8, 3, 7]
Output: 49
Explanation: the lines with heights 8 and 7 form the container with an area of 49 (7 * 7).
Example 3:
01
Input: lines = [1, 1]
Output: 1
Explanation: 1 * 1 = 1.
Constraints:
2 <= length of lines <= 10^50 <= lines[i] <= 10^4
def maxArea(lines: list[int]) -> int: pass 012345
Press Visualise to step through your code.