Using DP | Python
Complexity\n- Time complexity: O(m(n^2))\n\n- Space complexity: O(mn)\n\n# Code\n\nclass Solution:\n    def maximalRectangle(self, matrix: List[List[str]]) -> i
# Complexity\n- Time complexity: O(m(n^2))\n\n- Space complexity: O(mn)\n\n# Code\n```\nclass Solution:\n    def maximalRectangle(self, matrix: List[List[str]]) -> int:\n        m,n = len(matrix),len(matrix[0])\n        ans = 0\n        dp = {}\n\n        for i in range(m):\n            for j in range(n):\n                if matrix[i][j]==\'0\':\n                    dp[(i,j)]=(0,0)\n                else:\n                    x = dp[(i,j-1)][0]+1 if j>0 else 1\n                    y = dp[(i-1,j)][1]+1 if i>0 else 1\n                    dp[(i,j)] = (x,y)\n                    ans = max(x,y,ans)\n                    minWidth = x\n                    # verical max possible\n                    for r in range(i-1,i-y,-1):\n                        minWidth = min(minWidth,dp[(r,j)][0])\n                        ans = max(ans,minWidth*(i-r+1))\n        \n        \n        return ans\n```
['Array', 'Dynamic Programming', 'Matrix', 'Python', 'Python3']