Skip to content

Commit 1c6aea7

Browse files
Add files via upload
1 parent 1ffa7d8 commit 1c6aea7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

containwater.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def maxArea(height):
2+
left = 0
3+
right = len(height) - 1
4+
max_water = 0
5+
while left < right:
6+
width = right - left
7+
current_water = min(height[left], height[right]) * width
8+
max_water = max(max_water, current_water)
9+
if height[left] < height[right]:
10+
left += 1
11+
else:
12+
right -= 1
13+
return max_water
14+
height = [1,8,6,2,5,4,8,3,7]
15+
print(maxArea(height))

0 commit comments

Comments
 (0)