11. Container With Most Water C++

方法1:Brute Force(执行时间惨不忍睹,共进行)

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

猜你喜欢

转载自www.cnblogs.com/tornado549/p/9949825.html