-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaxWater.py
28 lines (20 loc) · 906 Bytes
/
MaxWater.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'''You are given an integer array heights where heights[i] represents the height of the i'th bar.
You may choose any two bars to form a container. Return the maximum amount of water a container can store.'''
def maxArea(height):
waters = []
if len(height) <= 1 :
return 0
for counter_1 in range(len(height)):
for counter_2 in range(len(height)):
width = abs(counter_2-counter_1)
if counter_1 == counter_2:
pass
else:
if height[counter_1] > height[counter_2]:
length = height[counter_2]
else:
length = height[counter_1]
area = length*width
waters.append(area)
return max(waters)
print(maxArea([2]))