Completes 52/61 test cases
This commit is contained in:
parent
1f1479e39a
commit
d8d82396e3
@ -1,5 +1,24 @@
|
||||
def maxArea(self, height):
|
||||
def maxArea(height):
|
||||
"""
|
||||
:type height: List[int]
|
||||
:rtype: int
|
||||
"""
|
||||
"""
|
||||
n = len(height)
|
||||
container = []
|
||||
|
||||
# Handle edge-case
|
||||
if n == 2:
|
||||
return min(height)
|
||||
|
||||
for i in range(n):
|
||||
for j in range(i+1,n):
|
||||
index = min(height[i], height[j])
|
||||
dist = j-i
|
||||
container.append(index*dist)
|
||||
return max(container)
|
||||
# return container
|
||||
|
||||
print(maxArea([1,8,6,2,5,4,8,3,7])) #Output: 49
|
||||
print(maxArea([1,2,1])) #Output: 2
|
||||
print(maxArea([1,2])) #Output: 1
|
||||
print(maxArea([1,2,4,3])) #Output: 4
|
||||
Loading…
Reference in New Issue
Block a user