class Solution {
public:
int maxArea(vector<int>& height) {
int left=0;
int right=height.size()-1;
int s=right;
int an=0;
int flag=1;
while(left!=s&&right!=0)
{
int d=(right-left)*min(height[left],height[right]);
an=max(an,d);
if(height[left]>height[right])
right--;
else
left++;
}
return an;
}
};
贪心,每次相当于算当前长度最大盛水量,有点难想