Container With Most Water

Posted PirateLHX

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
        
        

  

以上是关于Container With Most Water的主要内容,如果未能解决你的问题,请参考以下文章

11 Container With Most Water

LeetCode11-Container With Most Water

LeetCode11. Container With Most Water 解题报告

Container with most water

Container With Most Water

Container With Most Water