class Solution {
public:
int maxArea(vector<int>& height) {
int left = 0, right = height.size() - 1;
int ans = 0;
while(left < right){
ans = max(ans, (right - left) * min (height[right], height[left]));
if(height[left] <= height[right]){
left++;
}else{
right--;
}
}
return ans;
}
};
盛最多水的容器
最新推荐文章于 2025-05-19 20:18:50 发布