Skip to content

Instantly share code, notes, and snippets.

@ksamirdev
Created April 12, 2026 05:49
Show Gist options
  • Select an option

  • Save ksamirdev/74367e57c2d64083521103b883766e87 to your computer and use it in GitHub Desktop.

Select an option

Save ksamirdev/74367e57c2d64083521103b883766e87 to your computer and use it in GitHub Desktop.
class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
left, right = 0, len(height) - 1
maxArea = 0
while left < right:
h = min(height[left], height[right])
dist = right - left
area = dist * h
maxArea = max(maxArea, area)
if height[left] > height[right]:
right -= 1
else:
left += 1
return maxArea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment