10 line c++ solution
\n\n    class Solution {\n    public:\n        int largestRectangleArea(vector& heights) {\n            int res = 0;\n            for (int i = 0; i < heights.si
\n\n    class Solution {\n    public:\n        int largestRectangleArea(vector<int>& heights) {\n            int res = 0;\n            for (int i = 0; i < heights.size(); ++i) {\n                if (i + 1 < heights.size() && heights[i] <= heights[i+1]) continue; // find the local max (greater than left and right)\n                int minh = heights[i];\n                for (int j = i; j >= 0; --j) {\n                    minh = min(minh, heights[j]);\n                    res = max(res, minh * (i - j + 1));\n                }\n            }\n            return res;\n        }\n    };
['C++']