class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param height int整型vector
* @return int整型
*/
int maxArea(vector<int>& height) {
// write code here
if(height.size()<=1) return 0;
int res=0;
int left=0,right=height.size()-1;
int maxR=0,maxL=0;
while(left<right){
maxL=max(maxL,height[left]);
maxR=max(maxR,height[right]);
if(maxR>maxL){
res=max(res,maxL*(right-left));
left++;
}else{
res=max(res,maxR*(right-left));
right--;
}
}
return res;
}
};