容器盛水

class Solution:
    def maxArea(self, height: List[int]) -> int:
        # 双指针,每次移动短指针
        i = 0
        j = len(height) - 1

        res = 0

        while i <= j:
            if height[i] < height[j]:
                s = height[i] * (j-i)
                i += 1
            else:
                s = height[j] * (j-i)
                j -= 1
            res = max(s, res)
        return res
        


原文地址:https://www.cnblogs.com/KbMan/p/14499833.html