LeetCode1.6

作者: supermanwasd | 来源:发表于2019-01-06 22:45 被阅读0次

Container With Most Water

Screen Shot 2019-01-06 at 10.42.23 PM.png Screen Shot 2019-01-06 at 10.42.29 PM.png

答案:

   class Solution:
    def maxArea(self, height):
        """
        :type height: List[int]
        :rtype: int
        """
        min_,max_= 0,len(height)-1
        areas = 0
        while min_ != max_:
            if height[min_] < height[max_]:
                areas = max((max_-min_)*height[min_],areas)
                min_ +=1
            else:
                areas = max((max_-min_)*height[max_],areas)
                max_ -=1
        return areas

相关文章

网友评论

    本文标题:LeetCode1.6

    本文链接:https://www.haomeiwen.com/subject/uswerqtx.html