Skip to content

Instantly share code, notes, and snippets.

@ghabs
Created October 20, 2017 21:29
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 ghabs/73424a23b1ebec01537610f0391102d8 to your computer and use it in GitHub Desktop.
Save ghabs/73424a23b1ebec01537610f0391102d8 to your computer and use it in GitHub Desktop.
class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
max_x = len(height) - 1;
i = 0
max_area = 0
while (i != max_x):
if height[i] > height[max_x]:
max_area = max(max_area, (max_x - i) * height[max_x])
max_x = max_x - 1
elif height[max_x] >= height[i]:
max_area = max(max_area, (max_x - i) * height[i])
i = i + 1
return max_area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment