Short C++ solution use stack AC 28ms
class Solution {\n    public:\n        int largestRectangleArea(vector<int>& height) {\n            height.push_back(0);\n            int result=0;\n           
    class Solution {\n    public:\n        int largestRectangleArea(vector<int>& height) {\n            height.push_back(0);\n            int result=0;\n            stack<int> indexStack;\n            for(int i=0;i<height.size();i++){\n                while(!indexStack.empty()&&height[i]<height[indexStack.top()]){\n                    int top=indexStack.top();\n                    indexStack.pop(); \n                    int nextTop=indexStack.size()==0?-1:indexStack.top();\n                    result=max((i-nextTop-1)*height[top],result);\n                }\n                indexStack.push(i);\n            }\n            return result;\n        }\n    };
[]