11. Container With Most Water
https://leetcode.com/problems/container-with-most-water/
solution
class Solution:
    def maxArea(self, height: List[int]) -> int:
        l = 0
        r = len(height) - 1
        res = 0
        while l < r:
            res = max(res, min(height[l], height[r]) * (r - l))
            if height[l] < height[r]:
                l += 1
            elif height[l] > height[r]:
                r -= 1
            else:
                l += 1
                r -= 1
        return res时间复杂度:O(1) 空间复杂度:O(1)
Last updated