class Solution { public: int maxArea(vector<int>& height) { int res=0,l=0,r=height.size()-1; while(l<r) { int mi=min(height[l],height[r]); res=max(res,mi*(r-l)); int tem=height[r]; if(height[l]==height[r]) while(l<r&&height[--r]<tem); else if(height[l]<height[r])l++; else r--; } return res; } };