Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created February 26, 2020 17:14
Show Gist options
  • Save deque-blog/c2c8d9d62c44261ea7499f468cace536 to your computer and use it in GitHub Desktop.
Save deque-blog/c2c8d9d62c44261ea7499f468cace536 to your computer and use it in GitHub Desktop.
def maxArea(heights: List[int]) -> int:
i = 0
j = len(heights) - 1
max_area = 0
while i < j:
width = j - i
height = min(heights[i], heights[j])
max_area = max(max_area, width * height)
if heights[i] < heights[j]:
i += 1
else:
j -= 1
return max_area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment