11. Container With Most Water
mediumArray · Two Pointers · Greedy
read the problem on leetcode →
first solved 15 Sept 2026
class Solution:
def maxArea(self, height: List[int]) -> int:
left = 0
right = len(height) - 1
max_area = 0
while left < right:
width = right - left
current_height = min(height[left], height[right])
max_area = max(max_area, width * current_height)
if height[left] < height[right]:
left += 1
else:
right -= 1
return max_area