Skip to content

Instantly share code, notes, and snippets.

@parcar
Created August 22, 2019 16:47
Show Gist options
  • Select an option

  • Save parcar/cf22c2b6323ef8a46dd584708b8e2410 to your computer and use it in GitHub Desktop.

Select an option

Save parcar/cf22c2b6323ef8a46dd584708b8e2410 to your computer and use it in GitHub Desktop.
class Solution:
def maxArea(self, height: List[int]) -> int:
lo = 0
hi = len(height)-1
cmax = 0
while(lo < hi):
cmax = max(min(height[lo],height[hi]) * (hi - lo), cmax)
if (height[lo] > height[hi]):
hi -= 1
else:
lo += 1
return cmax
'''
Runtime: 144 ms, faster than 65.36% of Python3 online submissions for Container With Most Water.
Memory Usage: 15.5 MB, less than 5.26% of Python3 online submissions for Container With Most Water.
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment