python using stack
\nclass Solution:\n    def largestRectangleArea(self, heights: List[int]) -> int:\n        ans = 0\n        stack = []\n        heights = [0] + heights + [0]\n 
```\nclass Solution:\n    def largestRectangleArea(self, heights: List[int]) -> int:\n        ans = 0\n        stack = []\n        heights = [0] + heights + [0]\n        for i in range(len(heights)):\n            while(stack and heights[stack[-1]] > heights[i]):\n                j = stack.pop()\n                ans = max(ans, (i-stack[-1]-1)*heights[j])\n            stack.append(i)\n        return ans\n```\t\t
['Stack', 'Python']