Skip to content

Instantly share code, notes, and snippets.

@rdtr
Created January 4, 2016 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdtr/46f21144efa9dd84b9f8 to your computer and use it in GitHub Desktop.
Save rdtr/46f21144efa9dd84b9f8 to your computer and use it in GitHub Desktop.
class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
leng = len(height)
if leng <= 1: 0
res = 0
left, right = 0, leng - 1
while left != right:
hl = height[left]
hr = height[right]
if hl < hr: h = hl
else: h = hr
v = h * (right - left)
if v > res: res = v
if hl < hr:
left += 1
else:
right -= 1
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment