leetcode 11. Container With Most Water

来源:互联网 发布:淘宝手机触摸屏 编辑:程序博客网 时间:2024/06/08 16:21

int maxArea(vector<int>& height){

    int left =0 , right = height.size()-1 , maxA=0;

    while(left<right){

        int tmp = (right - left)*(height[right]<height[left]?height[right--]:height[left++]);

        maxA = max(maxA,tmp);

    }

    return maxA;

}

0 0
原创粉丝点击