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;
      
    }
};
posted @ 2019-06-20 17:21 Shendu.CC 阅读(...) 评论(...) 编辑 收藏