LeetCode(11)

class Solution {
public:
    int maxArea(vector<int>& height) {
        int i = 0,j = height.size()-1,result = 0;
        while(i<j){
            int h = min(height[i],height[j]);
            result = max(result,h*(j-i));
            if(height[i]>height[j])
                j--;
            else
                i++;
        }
        return result;
    }
};

 

posted @ 2021-12-30 09:37  智人心  阅读(22)  评论(0)    收藏  举报