#include<algorithm>
class Solution {
public:
int maxArea(vector<int>& height) {
int i=0,j=height.size()-1,mx=0;
while(i<j)
{
if(height[i]<height[j])
{
mx=max(mx,height[i]*(j-i));
i++;
}
else{
mx=max(mx,height[j]*(j-i));
j--;
}
}
return mx;
}
};
c++实现盛最多水的容器
最新推荐文章于 2022-11-19 10:35:00 发布