We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0ee07e9 commit 6b99200Copy full SHA for 6b99200
0011-container-with-most-water/solution.py
@@ -0,0 +1,22 @@
1
+class Solution:
2
+ def maxArea(self, height: List[int]) -> int:
3
+ res = 0
4
+ l, r = 0, len(height) - 1
5
+
6
+ while l < r:
7
+ # AREA = L * B where
8
+ # L = length of container (r-l) Index.
9
+ # B = the most minimum height from both sides of the container.
10
+ temp = (r-l) * min(height[l], height[r])
11
+ res = max(res,temp)
12
13
+ # proceed while keeping the maximum height.
14
+ # for example, if left tower is higher than the right,
15
+ # then calculate area for the next right tower (r--)
16
17
+ if height[l] > height[r]:
18
+ r -= 1
19
+ else:
20
+ l += 1
21
22
+ return res
0 commit comments