11. Container With Most Water
Approach 1: Brute Force
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
lh = len(height)
max_vol = -1
for i in range(lh):
for j in range(i+1, lh):
if i == j:
continue
if (j-i)*min(height[i],height[j]) > max_vol:
max_vol = (j-i)*min(height[i],height[j])
return max_volApproach 2: Two Ends Approach
Last updated