11. Container With Most Water
class Solution {
public:
int maxArea(vector<int>& height)
{
int left = 0, right = height.size() - 1;
int res = 0, curArea = 0;
while(left < right)
{
curArea = min(height[left], height[right]) * (right - left);
res = max(res, curArea);
if(height[left] < height[right]) ++left;
else --right;
}
return res;
}
};
- T:
- S: