Container With Most Water LeetCode solution in Python

1
class Solution:
2
def maxArea(self, H: List[int]) -> int:
3
ans, i, j = 0, 0, len(H) - 1
4
while i < j:
5
if H[i] <= H[j]:
6
res = H[i] * (j - i)
7
i += 1
8
else:
9
res = H[j] * (j - i)
10
j -= 1
11
if res > ans:
12
ans = res
13
return ans

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0