Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created February 26, 2020 17:18
Show Gist options
  • Select an option

  • Save deque-blog/a72e8fe1bd6dc2f70a96aa9d9c501772 to your computer and use it in GitHub Desktop.

Select an option

Save deque-blog/a72e8fe1bd6dc2f70a96aa9d9c501772 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
if heights[i] < heights[j]:
max_area = max(max_area, width * heights[i])
i += 1
else:
max_area = max(max_area, width * heights[j])
j -= 1
return max_area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment