美文网首页
11. Container With Most Water

11. Container With Most Water

作者: chaowwwww | 来源:发表于2018-04-11 09:14 被阅读0次
    class Solution:
        def maxArea(self, height):
            """
            :type height: List[int]
            :rtype: int
            """
            ans = 0
            l = 0
            r = len(height) - 1
            while l < r:
                w = min(height[l], height[r])
                ans = max(ans, w * (r - l))
                if height[l] < height[r]:
                    l += 1
                else:
                    r -= 1
            return ans

    相关文章

      网友评论

          本文标题:11. Container With Most Water

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