Created
February 26, 2020 17:14
-
-
Save deque-blog/c2c8d9d62c44261ea7499f468cace536 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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