My concise C++ solution, AC 90 ms
I push a sentinel node back into the end of height to make the code logic more concise.\n  \n\n      class Solution {\n        public:\n            int largestR
I push a sentinel node back into the end of height to make the code logic more concise.\n  \n\n      class Solution {\n        public:\n            int largestRectangleArea(vector<int> &height) {\n                \n                int ret = 0;\n                height.push_back(0);\n                vector<int> index;\n                \n                for(int i = 0; i < height.size(); i++)\n                {\n                    while(index.size() > 0 && height[index.back()] >= height[i])\n                    {\n                        int h = height[index.back()];\n                        index.pop_back();\n                        \n                        int sidx = index.size() > 0 ? index.back() : -1;\n                        if(h * (i-sidx-1) > ret)\n                            ret = h * (i-sidx-1);\n                    }\n                    index.push_back(i);\n                }\n                \n                return ret;\n            }\n        };
[]