Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 538 Bytes

11.md

File metadata and controls

24 lines (20 loc) · 538 Bytes
class Solution(object):
    def maxArea(self, height):
        """
        :type height: List[int]
        :rtype: int
        """
        a = 0
        b = len(height) - 1
        mymax = min(height[a], height[b]) * (b - a)
        while a < b:
            if min(height[a], height[b]) * (b - a) > mymax:
                mymax = min(height[a], height[b]) * (b - a)
            if height[a] < height[b]:
                a += 1
            else:
                b -= 1
        
        return mymax
        

从两边搜索