faster than 88.25% [easy-understanding][c++][stack]
\n      class Solution {\n            public:\n                int largestRectangleArea(vector& heights) {\n                    stack s;\n                    in
\n      class Solution {\n            public:\n                int largestRectangleArea(vector<int>& heights) {\n                    stack<int> s;\n                    int maxArea = 0;\n                    int area = 0;\n                    int i;\n                    for(i=0; i < heights.size();){\n                        if(s.empty() || heights[s.top()] <= heights[i]){\n                            s.push(i++);\n                        }else{\n                            int top = s.top();\n                            s.pop();      \n                            //if stack is empty means everything till i has to be\n                            //greater or equal to heights[top] so get area by\n                            //heights[top] * i;\n                            if(s.empty()){\n                                area = heights[top] * i;\n                            }\n                            //if stack is not empty then everythin from i-1 to   heights.top() + 1\n                            //has to be greater or equal to heights[top]\n                            //so area = heights[top]*(i - stack.top() - 1);\n                            else{\n                                area = heights[top] * (i - s.top() - 1);\n                            }\n                            if(area > maxArea){\n                                maxArea = area;\n                            }\n                        }\n                    }\n                    while(!s.empty()){\n                        int top = s.top();\n                        s.pop();\n                        //if stack is empty means everything till i has to be\n                        //greater or equal to heights[top] so get area by\n                        //heights[top] * i;\n                        if(s.empty()){\n                            area = heights[top] * i;\n                        }\n                        //if stack is not empty then everything from i-1 to       height.top() + 1\n                        //has to be greater or equal to heights[top]\n                        //so area = heights[top]*(i - stack.top() - 1);\n                        else{\n                            area = heights[top] * (i - s.top() - 1);\n                        }\n                    if(area > maxArea){\n                            maxArea = area;\n                        }\n                    }\n                    return maxArea;\n                }\n            };\n\t  \n**Feel free to ask any question in the comment section.\nIf you like this solution, do UPVOTE.\nHappy Coding :)**\n\t
['Stack', 'C', 'C++']