```
int maxArea(vector<int> &height) {
int i = 0;
int j = height.size();
int maxVal = 0;
while(i < j) {
int minHeight = 0;
if (height[i] < height[j]) {
minHeight = height[i];
++i;
} else {
minHeight = height[j];
--j;
}
int area = (j-i+1)*minHeight;
if (maxVal < area) {
maxVal = area;
}
}
return maxVal;
}
```