My super concise c++ solution


  • 0
    X
    class Solution {
    public:
        int maxArea(vector<int>& height) 
        {
            int res=0,left=0,right=height.size()-1;
            while(left<right)
            {
                int lower=height[height[left]<height[right]?left++:right--];
                res=max(res,(right-left+1)*lower);
            }
            return res;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.