Easy Solution || C++
Tabulation code : Dynamic Programming : Idea behind this\nTaking a small refernce from largest rectangle area Question , where we have to calculate largest area
**Tabulation code : Dynamic Programming** : Idea behind this\nTaking a small refernce from largest rectangle area Question , where we have to calculate largest area possible by using stack approach. We can boil down this problem in sub - problem that are related to the largest rectangle area problem . where in this we traverse this matrix for every value of j from 0 to m , if the matrix value at that particular is 1 then we just increment the height vector that we have consider. at each traversal of i we calculate the area at the last from the refrence question . calculate the max at the last.\n\n```\n// Maximal Rectangle\n    // tab\n        class Solution {\n        public:\n            int largestRectangleArea(vector < int > & histo) {\n            stack < int > st;\n            int maxA = 0;\n            int n = histo.size();\n            for (int i = 0; i <= n; i++) {\n                while (!st.empty() && (i == n || histo[st.top()] >= histo[i])) {\n                int height = histo[st.top()];\n                st.pop();\n                int width;\n                if (st.empty())\n                    width = i;\n                else\n                    width = i - st.top() - 1;\n                maxA = max(maxA, width * height);\n                }\n                st.push(i);\n            }\n            return maxA;\n            }\n            int maximalRectangle(vector<vector<char>>& matrix) {\n                int maxiArea = 0, n = matrix.size(), m = matrix[0].size();\n                vector<int> height(m,0);\n                \n                for(int i=0;i<n;i++){\n                    for(int j=0;j<m;j++){\n                        if(matrix[i][j] == \'1\') height[j]++;\n                        else height[j] = 0;\n                    }   \n                    int area = largestRectangleArea(height);\n                    maxiArea = max(maxiArea,area);\n                }\n                return maxiArea;\n            }\n        };\n```\n<br>\n<div>Happy Coding</div>\nPlease do upvote this post. \n\n![image](https://assets.leetcode.com/users/images/5ce11bf6-0db9-4239-bbb9-dfe5d76443f3_1666346629.9681695.gif)
['Dynamic Programming', 'Stack', 'C', 'Monotonic Stack', 'C++']