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