Container With Most Water

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

  

原文地址:https://www.cnblogs.com/xlqtlhx/p/8228288.html