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 f2daef6 commit 1f36003Copy full SHA for 1f36003
container-with-most-water/printjin-gmailcom.py
@@ -1,13 +1,8 @@
1
class Solution:
2
def maxArea(self, height):
3
- left, right = 0, len(height) - 1
4
max_area = 0
5
- while left < right:
6
- h = min(height[left], height[right])
7
- w = right - left
8
- max_area = max(max_area, h * w)
9
- if height[left] < height[right]:
10
- left += 1
11
- else:
12
- right -= 1
+ for i in range(len(height)):
+ for j in range(i + 1, len(height)):
+ area = (j - i) * min(height[i], height[j])
+ max_area = max(max_area, area)
13
return max_area
0 commit comments