Leetcode Medium 4 Container With Most Water

class Solution:
    def maxArea(self, height):
        max_pool = 0
        i, j = 0, len(height)-1
        while i < j:
            if height[i] < height[j]:
                max_pool = max(max_pool, height[i]*(j-i))
                i += 1
            else:
                max_pool = max(max_pool, height[j]*(j-i))
                j -= 1
        return max_pool

猜你喜欢

转载自blog.csdn.net/li_k_y/article/details/86485135