Simple JavaScript Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nJust Solve this Problem like any other stack problem of nearest minimum.\n\n# Approach\
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nJust Solve this Problem like any other stack problem of nearest minimum.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Find the nearest minimum elements for the left side of the given array.\n2. Find the nearest minimum elements for the right side of the given array. \n3. Find the area of all the elements.\n4. For Area you have to find length and breadth is given. So for length just Step 1 stack subtract Step 2 Stack, you will get the length.\n5. Then just take the maximum one out and return. \n\n# Complexity\n- Time complexity: N\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: N\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[]} heights\n * @return {number}\n */\nvar largestRectangleArea = function(heights) {\n    let leftStack = [];\n    let stack = [];\n    \n//Left side nearest minimum element\n    for(let i = 0;i < heights.length;i++){\n        while(stack.length !== 0 && heights[stack[stack.length - 1]] >= heights[i]){\n            stack.pop();\n        }\n\n        if(stack.length === 0){\n            leftStack.push(-1);\n        }\n        else {\n            leftStack.push(stack[stack.length - 1]);\n        }\n        stack.push(i);\n    }\n\n//Right side nearest minimum element \n    stack = [];\n    let rightStack = [];\n\n    for(let i = heights.length - 1;i >= 0; i--){\n        while(stack.length !== 0 && heights[stack[stack.length - 1]] >= heights[i]){\n            stack.pop();\n        }\n\n        if(stack.length === 0){\n            rightStack.push(heights.length);\n        }\n        else {\n            rightStack.push(stack[stack.length - 1]);\n        }\n        stack.push(i);\n    }\n    \n    //Calculating maximum  Area \n    let max = -Infinity;\n    let area;\n    //Area = right - left - 1 (length) * heights[i](breadth)\n\n    for(let i = 0;i < heights.length; i++){\n        area = (rightStack[heights.length - i - 1] - leftStack[i] - 1)  * heights[i];\n        max = Math.max(area,max);\n    }\n    return max;\n};\n```
['Array', 'Stack', 'Monotonic Stack', 'JavaScript']