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 85ef569 commit a199b08Copy full SHA for a199b08
1 file changed
container-with-most-water/jylee2033.py
@@ -0,0 +1,19 @@
1
+class Solution:
2
+ def maxArea(self, height: List[int]) -> int:
3
+ left = 0
4
+ right = len(height) - 1
5
+ area = min(height[left], height[right]) * (right - left)
6
+
7
+ while left < right:
8
+ if height[left] < height[right]:
9
+ left += 1
10
+ else:
11
+ right -= 1
12
13
+ new_area = min(height[left], height[right]) * (right - left)
14
+ area = max(area, new_area)
15
16
+ return area
17
18
+# Time Complexity: O(n)
19
+# Space Complexity: O(1)
0 commit comments