C++ Very Easy Solution Using Stack + 84. Largest Rectangle in Histogram
\nint largestRectangleArea(vector<int>& heights) {\n        int n=heights.size();\n        stack<int> s;\n        s.push(-1);\n        int maxArea=0;\n        i
```\nint largestRectangleArea(vector<int>& heights) {\n        int n=heights.size();\n        stack<int> s;\n        s.push(-1);\n        int maxArea=0;\n        int rm=0,lm=0;\n        for(int i=0;i<=n;i++)\n        {\n            int val = (i==n ? 0 : heights[i]);\n            while(s.top() != -1 and heights[s.top()]>=val)\n            {\n                rm = i;\n                int h = heights[s.top()];\n                s.pop();\n                lm = s.top();\n                maxArea = max(maxArea, h*(rm-lm-1));\n            }\n            s.push(i);\n        }\n        return maxArea;\n    }\n    int maximalRectangle(vector<vector<char>>& matrix){\n        int row = matrix.size();\n        if(row == 0) return 0;\n        int col = matrix[0].size();\n    \n        vector<int> v(col);\n        for(int i=0;i<col;i++)\n        {\n            v[i] = matrix[0][i] - \'0\';\n        }\n        int maxArea = 0;\n        maxArea = max(maxArea, largestRectangleArea(v));\n        for(int i=1;i<row;i++)\n        {\n            for(int j=0;j<col;j++)\n            {\n                if(matrix[i][j]==\'1\')\n                {\n                    v[j]++;\n                }\n                else\n                {\n                    v[j]=0;\n                }\n            }\n            maxArea = max(maxArea, largestRectangleArea(v));\n        }\n        return maxArea;\n    }\n```
[]