16ms [c++] 10-line code with stack
int largestRectangleArea(vector<int>& height) {\n        height.push_back(0); \n        int len = height.size(),res = 0, cur=1;\n        int s[len+1]={0};\n    
    int largestRectangleArea(vector<int>& height) {\n        height.push_back(0); \n        int len = height.size(),res = 0, cur=1;\n        int s[len+1]={0};\n        s[0]=-1;\n        for(int i=1;i<len;i++){\n            while(cur && height[i]<height[s[cur]])\n                res = max(res, height[s[cur]] * (i-s[--cur]-1));\n            s[++cur]=i;\n        }\n        return res;\n    }\nThe idea is simply to insert position -1 to the beginning of the stack s, therefore we don't need to check whether the stack is empty or not. \nFor the height, push a "0" to the end to update the result until the last element in the height.\nHere I use an int array to simulate the stack for better time performance.
['C++']