LeetCode 11. Container With Most Water

题目

class Solution {
public:
    int s[10005];
    int maxArea(vector<int>& height) {
        int ans=0;
        int l=0;
        int r=height.size()-1;
        while(l<r)
        {
            ans=max(ans,min(height[l],height[r])*(r-l));
            if(height[l]<=height[r])
                l++;
            else
                r--;
        }
        return ans;
      
    }
};
原文地址:https://www.cnblogs.com/dacc123/p/11060016.html