Python O(row*col) using histogram
\n\n\nclass Solution:\n    def maximalRectangle(self, matrix: List[List[str]]) -> int:\n        if not matrix:\n            return 0\n        row=len(matrix)\n 
![image](https://assets.leetcode.com/users/images/cf0c802f-690c-4c93-a4bb-8f2c10e032c9_1624947641.2761607.jpeg)\n\n```\nclass Solution:\n    def maximalRectangle(self, matrix: List[List[str]]) -> int:\n        if not matrix:\n            return 0\n        row=len(matrix)\n        col=len(matrix[0])\n        histograms=[[0]*col for _ in range(row)]\n        for i in range(row):\n            for j in range(col):\n                if i==0:\n                    histograms[i][j]=int(matrix[i][j])\n                else:\n                    if int(matrix[i][j])==0:\n                        histograms[i][j]=0\n                    else:\n                        histograms[i][j]=histograms[i-1][j]+int(matrix[i][j])\n        def maxArea(arr):\n            stack=[]\n            i=0\n            Max=0\n            while i<len(arr):\n                if not stack or arr[i]>=arr[stack[-1]]:\n                    stack.append(i)\n                    i+=1\n                else:\n                    a=stack.pop()\n                    area=arr[a]*((i-stack[-1]-1) if stack else i)\n                    Max=max(area,Max)\n            pre=stack[-1]\n            while stack:\n                a=stack.pop()\n                area=arr[a]*((pre-stack[-1]) if stack else pre+1)\n                Max=max(area,Max)\n            return Max\n        k=0\n        for i in histograms:\n            k=max(k,maxArea(i))\n        return k\n                    \n                    \n                \n```
['Python', 'Python3']