Skip to content

Commit 61cb3bb

Browse files
committed
Time: 1 ms (99.90%) | Memory: 63.5 MB (30.48%) - LeetSync
1 parent 4edc44c commit 61cb3bb

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
public class Solution {
2+
public int MaxArea(int[] height) {
3+
int maxArea = 0;
4+
int left = 0;
5+
int right = height.Length - 1;
6+
7+
while (left < right){
8+
int w = right - left;
9+
int h = Math.Min(height[left], height[right]);
10+
11+
int currentArea = w * h;
12+
13+
maxArea = Math.Max(maxArea, currentArea);
14+
15+
if (height[left] < height[right]){
16+
left ++;
17+
}
18+
else{
19+
right --;
20+
}
21+
}
22+
23+
return maxArea;
24+
}
25+
}

0 commit comments

Comments
 (0)