class Solution(object): def maxArea(self, height): """ :type height: List[int] :rtype: int """ sum = 0 l = len(height) for i in range(1, l): for j in range(i): tmp = (i-j) * min(height[i],height[j]) if tmp>sum: sum = tmp return sum
class Solution(object): def maxArea(self, height): """ :type height: List[int] :rtype: int """ sum = 0 i= 0 j = len(height) - 1 while i<j: h = 0 b = j - 1 if height[i] < height[j]: h = height[i] i += 1 else: h = height[j] j -= 1 tmp = b * h if tmp > sum: sum = tmp return sum