Skip to content

Commit 1f36003

Browse files
Solve : Container With Most Water
1 parent f2daef6 commit 1f36003

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
class Solution:
22
def maxArea(self, height):
3-
left, right = 0, len(height) - 1
43
max_area = 0
5-
while left < right:
6-
h = min(height[left], height[right])
7-
w = right - left
8-
max_area = max(max_area, h * w)
9-
if height[left] < height[right]:
10-
left += 1
11-
else:
12-
right -= 1
4+
for i in range(len(height)):
5+
for j in range(i + 1, len(height)):
6+
area = (j - i) * min(height[i], height[j])
7+
max_area = max(max_area, area)
138
return max_area

0 commit comments

Comments
 (0)