Python 3 || 10 lines,  histogram || T/S: 99% / 80%
\nclass Solution:\n    def maximalRectangle(self, matrix: list[list[str]], ans = 0) -> int:\n\n        m, n = len(matrix), len(matrix[0])\n        dp = [0]*(n+1
```\nclass Solution:\n    def maximalRectangle(self, matrix: list[list[str]], ans = 0) -> int:\n\n        m, n = len(matrix), len(matrix[0])\n        dp = [0]*(n+1)\n        \n        for i in range(m):\n            stk = deque([-1])\n\n            for j in range(n+1):\n                if j < n and matrix[i][j] == \'1\': dp[j]+= 1\n                else: dp[j] = 0\n\n                while(dp[stk[0]] > dp[j]):\n                    ans = max(ans,dp[stk.popleft()]*(j-stk[0]-1))\n\n                stk.appendleft(j)\n\n        return ans\n        \n```\n[https://leetcode.com/problems/maximal-rectangle/submissions/1266891831/](https://leetcode.com/problems/maximal-rectangle/submissions/1266891831/\n)\n\n\n\nI could be wrong, but I think that time complexity is *O*(*MN*) and space complexity is *O*(*N*), in which *M* ~ `m` and *N* ~ `n`.
['Python3']