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 65c33ff commit a59d7bbCopy full SHA for a59d7bb
11-container-with-most-water/container-with-most-water.py
@@ -1,16 +1,20 @@
1
class Solution:
2
def maxArea(self, height: List[int]) -> int:
3
- max_area = float("-inf")
4
- l = 0
5
- r = len(height) -1
6
7
- while l < r:
+ i = 0
+ j = len(height)-1
+ ans = 0
8
9
- area = min(height[l], height[r]) * (r -l)
10
- max_area = max(max_area, area)
11
- if height[l] < height[r]:
12
- l +=1
+ while i < j:
+
+ find_height = min(height[i], height[j])
+ ans = max(ans ,find_height * (j-i))
+ print(ans)
13
14
+ if height[i] > height[j]:
15
+ j -=1
16
else:
- r -=1
-
- return max_area
17
+ i +=1
18
+ return ans
19
20
0 commit comments