container with most water

class Solution {
public:
int maxArea(vector& height) {

    int n=height.size();
    int i=0,j=n-1;
    int m=0;
    int c=0;
    while(i<j)
    {
        c=(j-i)*min(height[i],height[j]);
        if(c>m)
        m=c;
        
        if(height[i]>height[j])
             j--;
        else
            i++;
        
        
    }
    return m;
    
}

};

Comments (0)