class Solution {
public:
int maxArea(vector<int>& height) {
int maxarea = 0, l = 0, r = height.size() - 1;
while (l < r) {
maxarea = max(maxarea, min(height[l], height[r]) * (r - l));
if (height[l] < height[r])
l++;
else
r--;
}
return maxarea;
}
};
盛最多水的容器
最新推荐文章于 2024-08-04 23:34:29 发布