Skip to content

Latest commit

 

History

History
23 lines (22 loc) · 561 Bytes

11.md

File metadata and controls

23 lines (22 loc) · 561 Bytes

Solution

class Solution(object):
    def maxArea(self, height):
        """
        :type height: List[int]
        :rtype: int
        """
        i, j = 0, len(height) - 1
        area = 0
        while i < j:
            h = min(height[i], height[j])
            area = max((j - i) * h, area)
            if height[i]< height[j]:
                while height[i] <= h and i < j:
                    i += 1
            else:
                while height[j] <= h and i < j:
                    j -= 1
        return area