Simple JS O(n) solution


  • 0
    R
    var maxArea = function(height) {
        maxContainer = 0;
        left = 0;
        right = height.length-1;
        for(i = 0; i < height.length; i++) {
            currContainer = Math.min(height[left],height[right])*(right-left);
            maxContainer = (currContainer > maxContainer ? currContainer : maxContainer)
            (height[left] > height[right] ? right-- : left++);
        }
        return maxContainer; 
    };

Log in to reply
 

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