Leetcode-Python 盛最多水的容器

Leetcode-Python 盛最多水的容器_第1张图片

class Solution:
    def maxArea(self, height: [int]) -> int:
        area = 0
        y = len(height)-1
        x = 0
        while x != y:
            a = min(height[y],height[x]) * abs(x-y)
            if a > area:
                area = a
            if height[x] < height[y]:
                x += 1
            else:
                y -= 1               
        return area

github项目地址:https://github.com/JockWang/LeetCode-Python

你可能感兴趣的:(Leetcode)