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
        


相关文章:

  • 2021-08-21
  • 2021-05-23
  • 2021-06-06
猜你喜欢
  • 2021-04-15
  • 2021-08-27
  • 2022-12-23
  • 2021-11-25
相关资源
相似解决方案