My simple JS solution


  • 1
    K
    var maxArea = function(height) {
    var s=0, max=0;
    var e=height.length-1;
    var current;
    while(s < e)
    {
       if(height[s]<height[e]){
           current=(e-s)*height[s];
           s++;
       }
       else {
           current=(e-s)*height[e];
           e--;
       }
       if(current>max)max=current;
    }
    return max;
    

    };


Log in to reply
 

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