// 每次都是短板进行移动,只有这样才可能提高容积
class Solution {
public:
int maxArea(vector<int>& height)
{
int l=0;
int r=height.size()-1;
if(height.size()<=1) return 0;
int area=0;
while(l<r)
{
area=max( area,(r-l)*(min(height[r],height[l])) );
if(height[l]<height[r])
{
l++;
}
else
{
r--;
}
}
return area;
}
};
[leetcode]11. Container With Most Water
最新推荐文章于 2018-08-13 17:38:00 发布