代码如下:
class Solution {
public:
int maxArea(std::vector<int>& height) {
int res=0;
int left=0;
int right=height.size()-1;
while (left<right)
{
int s=(right-left)*std::min(height[left],height[right]);
res=s>res?s:res;
if(height[left]<height[right])
left++;
else
right--;
}
return res;
}
};