Skip to content

Commit a59d7bb

Browse files
committed
Time: 662 ms (5.06%) | Memory: 29.9 MB (14.40%) - LeetSync
1 parent 65c33ff commit a59d7bb

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
class Solution:
22
def maxArea(self, height: List[int]) -> int:
3-
max_area = float("-inf")
4-
l = 0
5-
r = len(height) -1
63

7-
while l < r:
4+
i = 0
5+
j = len(height)-1
6+
ans = 0
87

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
8+
while i < j:
9+
10+
find_height = min(height[i], height[j])
11+
ans = max(ans ,find_height * (j-i))
12+
print(ans)
13+
14+
if height[i] > height[j]:
15+
j -=1
1316
else:
14-
r -=1
15-
16-
return max_area
17+
i +=1
18+
return ans
19+
20+

0 commit comments

Comments
 (0)