Leetcode-11 Posted on 2019-06-03 | | 阅读数 Words count in article: 78 | Reading time ≈ 1 Question Solution建立两个指针,从左右向中间遍历。用宽度来循环。 123456789class Solution: def maxArea(self, height: List[int]) -> int: l, r, width, res = 0, len(height) - 1, len(height) - 1, 0 for w in range(width, 0, -1): if height[l] < height[r]: l, res = l + 1, max(res, height[l] * w) else: r, res = r - 1, max(res, height[r] * w) return res