# 【LEETCODE】11-Container With Most Water [Python]

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.

Note: You may not slant the container.

http://segmentfault.com/a/1190000003815582

Python

class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""

if height==[]:
return 0

l=len(height)
ans=0

p1=0
p2=l-1

while p1<p2:

ans=max(ans,min(height[p1],height[p2])*(p2-p1))

if height[p1]<height[p2]:
p1+=1
else:
p2-=1

return ans