20230127 完美通过
20230128 完美通过
20230130 完美通过
20230202 完美通过
20230210 完美通过
20230225 完美通过
原题解

题目

约束

题解

class Solution {
public:
    int maxArea(vector<int>& height) {
        int l = 0, r = height.size() - 1;
        int ans = 0;
        while (l < r) {
            int area = min(height[l], height[r]) * (r - l);
            ans = max(ans, area);
            if (height[l] <= height[r]) {
                ++l;
            }
            else {
                --r;
            }
        }
        return ans;
    }
};
posted on 2023-01-26 23:40  垂序葎草  阅读(10)  评论(0编辑  收藏  举报