Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Solution {
public:
int maxArea(vector<int>& height) {
int len = height.size();
int l = 0, r = len-1, maxArea = 0;
while(l<r)
{
if(height[l] <= height[r])
{
maxArea = max(maxArea, (r - l)*height[l]);
l++;
}
else
{
maxArea = max(maxArea, (r - l)*height[r]);
r--;
}
}
return maxArea;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment