11. Container With Most Water

class Solution:
    def maxArea(self, height):
        """
        :type height: List[int]
        :rtype: int
        """
        ans = 0
        l = 0
        r = len(height) - 1
        while l < r:
            w = min(height[l], height[r])
            ans = max(ans, w * (r - l))
            if height[l] < height[r]:
                l += 1
            else:
                r -= 1
        return ans

你可能感兴趣的:(11. Container With Most Water)