Created
March 30, 2022 19:22
-
-
Save ThomasHigginson/b6b9ba9cc885321e171e535a2aa86b82 to your computer and use it in GitHub Desktop.
This file contains 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(self, height: List[int]) -> int: | |
i = 0 | |
j = len(height) - 1 | |
maxArea = -inf | |
currMax = -inf | |
while i < j: | |
currMax = min(height[i], height[j]) * (j - i) | |
maxArea = max(currMax, maxArea) | |
if height[i] < height[j]: | |
currIdx = i | |
while i < j and height[currIdx] >= height[i]: | |
i += 1 | |
else: | |
currIdx = j | |
while i < j and height[currIdx] >= height[j]: | |
j -= 1 | |
return maxArea |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment