largestRectangleArea = function(heights, maxArea = 0) {
    for (let i = 0; i < heights.length; i++) {/* Time O(N) */
        let min = Infinity;

        for (let j = i; j < heights.length; j++) {/* Time O(N) */
            min = Math.min(min, heights[j]);

            const area = min * ((j - i) + 1);

            maxArea = Math.max(maxArea, area);
        }
    }

    return maxArea;
}
https://leetcode.com/problems/largest-rectangle-in-histogram/solution/
Time O(N^2) | Space O(1)
@param {number[]} heights
@return {number}