Files
leetcode-hot100/test005.cpp
2025-08-14 19:44:02 +08:00

16 lines
369 B
C++

class Solution {
public:
int maxArea(vector<int>& height) {
int len = height.size();
int l = 0, r = len - 1;
int res = 0;
while(l < r){
int area = min(height[l],height[r]) * (r - l);
res = max(area, res);
if(height[l] > height[r]) r--;
else l++;
}
return res;
}
};