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