C++ || dp
\n\npublic:\n    int maximalRectangle(vector>& matrix) {\n        int i,j,k,n,m,minn,res=0;\n        n=matrix.size();\n        if(n==0)\n        {\n            
```\n\n```public:\n    int maximalRectangle(vector<vector<char>>& matrix) {\n        int i,j,k,n,m,minn,res=0;\n        n=matrix.size();\n        if(n==0)\n        {\n            return 0;\n        }\n        m=matrix[0].size();\n        vector<vector<int>>dp(n,vector<int>(m,0));\n        for(i=0;i<n;i++)\n        {\n            dp[i][m-1]=(int)matrix[i][m-1]-\'0\';\n            for(j=m-2;j>=0;j--)\n            {\n                if(matrix[i][j]==\'1\')\n                {\n                    dp[i][j]=dp[i][j+1]+1;\n                }\n            }\n        }\n        for(i=0;i<n;i++)\n        {\n            for(j=0;j<m;j++)\n            {\n                k=i;\n                minn=dp[i][j];\n                while(k<n&&dp[k][j])\n                {\n                    minn=min(minn,dp[k][j]);\n                    res=max(res,minn*(k-i+1));\n                    k++;\n                }\n            }\n        }\n        return res;\n    }\n};
[]