class Solution {
public int maxArea(int[] height) {
int n = height.length;
int left = 0;
int right = n - 1;
int maxA = 0;
while (left < right) {
int area = Math.min(height[left], height[right]) * (right - left);
maxA = Math.max(maxA, area);
if (height[left] < height[right]) {
left++;
} else {
right--;
}
}
return maxA;
}
}
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)