46. Container With Most Water

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Write a function solve that finds two lines that together with the x-axis forms a container, such that the container contains the most water.

Example:

Input: [1,8,6,2,5,4,8,3,7] Output: 49
Explanation: The two vertical lines are drawn at x = 1 and x = 8, and together with the x-axis forms a container with an area of 49. You may want to check the relevant leetcode question for more information.

Make sure you return your solution, don't print!


def solve(height):
    pass