Skip to content

Commit 08fe2ed

Browse files
committed
Time: 6 ms (34.66%), Space: 71.9 MB (75.80%) - LeetHub
1 parent be3e70c commit 08fe2ed

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int maxArea(int[] height) {
3+
int maxarea = 0, l = 0, r = height.length - 1;
4+
while(l < r) {
5+
maxarea = Math.max(maxarea, Math.min(height[l], height[r]) * (r - l));
6+
if(height[l] < height[r])
7+
l++;
8+
else
9+
r--;
10+
}
11+
return maxarea;
12+
}
13+
}

0 commit comments

Comments
 (0)