singularity

11. Container With Most Water

O(n)


var maxArea = function (height) {
    let n = height.length;
    let l = 0;
    let r = n - 1;
    let ma = 0;

    while (l < r) {
        w = r - l;
        let h = Math.min(height[l], height[r]);

        ma = Math.max(ma, w * h);

        if (height[l] < height[r]) {
            l += 1;
        } else {
            r -= 1;
        }
    }

    return ma;
};