#pragma region 11.盛最多水的容器
class Solution {
public:
int maxArea(vector<int>& height) {
if (height.size() <= 1) return -1;
int left = 0, right = height.size() - 1;
int maxS = 0;
while (left < right) {
maxS = max(maxS, (min(height[left], height[right]) * (right - left)));
height[left] < height[right] ? left++ : right--;
}
return maxS;
}
};
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)