Easy C++ Solution Based on Largest Stack || Stack
Complexity\n- Time complexity:\no(n^3)\n\n- Space complexity:\no(n)\n\n# Code\n\nclass Solution {\npublic:\n\nint largestRectangleArea(vector < int > & histo) {
# Complexity\n- Time complexity:\no(n^3)\n\n- Space complexity:\no(n)\n\n# Code\n```\nclass Solution {\npublic:\n\nint largestRectangleArea(vector < int > & histo) {\n\tstack < int > st;\n\tint maxA = 0;\n\tint n = histo.size();\n\tfor (int i = 0; i <= n; i++) {\n\t\twhile (!st.empty() && (i == n || histo[st.top()] >= histo[i])) {\n\t\t\tint height = histo[st.top()];\n\t\t\tst.pop();\n\t\t\tint width;\n\t\t\tif (st.empty())\n\t\t\t\twidth = i;\n\t\t\telse\n\t\t\t\twidth = i - st.top() - 1;\n\t\t\tmaxA = max(maxA, width * height);\n\t\t}\n\t\tst.push(i);\n\t}\n\treturn maxA;\n}\n\nint solve(vector<vector<char>>&mat, int n, int m) {\n\tint maxArea = 0;\n\tvector<int> height(m, 0);\n\tfor (int i = 0; i < n; i++) {\n\t\tfor (int j = 0; j < m; j++) {\n\t\t\tif (mat[i][j] == \'1\') height[j]++;\n\t\t\telse height[j] = 0;\n\t\t}\n\t\tint area = largestRectangleArea(height);\n\t\tmaxArea = max(area, maxArea);\n\t}\n\n\treturn maxArea;\n}\n\n\n    int maximalRectangle(vector<vector<char>>& matrix) {\n        int n = matrix.size();\n        int m = matrix[0].size();\n\n        return solve(matrix, n, m);\n    }\n};\n```
['Array', 'Stack', 'Matrix', 'Monotonic Stack', 'C++']