Easy Brute Force approach | C++
\nclass Solution {\npublic:\n    int largestRectangleArea(vector<int>& heights) {\n        int n=heights.size(),prev,next;\n        long long maxi=0;\n        f
```\nclass Solution {\npublic:\n    int largestRectangleArea(vector<int>& heights) {\n        int n=heights.size(),prev,next;\n        long long maxi=0;\n        for(int i=0;i<n;i++)\n        {\n            int c=1;\n            prev=i-1;\n            next=i+1;\n            while(prev>=0 && heights[i]<=heights[prev]) //if prev>=current\n            {\n                c++;\n                prev--;\n            }\n            while(next<n && heights[i]<=heights[next]) //if next>=current\n            {\n                c++;\n                next++;\n            }\n            long long area=heights[i]*c;\n            maxi=max(maxi,area);\n            int t=heights[i];\n            while(i<n && heights[i]==t) //for same heights\n            {\n                i++;          \n            }\n            i--;\n            \n        }\n        return maxi;\n    }\n};\n```
['C']