(( Swift )) 100% Beaten - Using Stack Trick... O(N) RunTime ComPlexiTY
\nclass Solution {\n    func largestRectangleArea(_ heights: [Int]) -> Int {\n        \n        var heights = heights\n        heights.append(0)\n        \n    
```\nclass Solution {\n    func largestRectangleArea(_ heights: [Int]) -> Int {\n        \n        var heights = heights\n        heights.append(0)\n        \n        var result = 0\n        \n        var stack = [Int]()\n        \n        for i in heights.indices {\n            \n            while stack.count > 0 && heights[i] <= heights[stack.last!] {\n                \n                var height = heights[stack.removeLast()]\n                var span = i\n                if stack.count > 0 {\n                    span = i - stack.last! - 1\n                }\n                result = max(result, span * height)\n            }\n            \n            stack.append(i)\n            \n        }\n        \n        return result\n    }\n}\n```\n\nBoom, baby, you are on the payroll. Insured and living large. Rollin\' like a big shot and giving back to the homies on the street.
[]