Simple Python3 | 9 Lines | Beats 100% | Detailed Explanation
Logic: Prefix sum from top to the bottom row for every column, by doing this we have number of continuous 1st stacked on top so far at matrix[i][j] . So for exa
Logic: Prefix sum from top to the bottom row for every column, by doing this we have number of continuous 1st stacked on top so far at matrix[i][j] . So for example if the matrix is \n[0,0,1]\n[1,1,1]\n[1,0,1]\nWe have the prefix summed matrix:\n[0, 0, 1]\n[1, 1, 2]\n[2, 0, 3]\nNow the we could just go row by row and check the maximum possible area till that row. In row one the maximum area can only be 1, in row two the max area can be 2 == matrix[1][2] or we could use matrix[1][1] and matrix[1][2] now we have a 1x1 matrix = area => 2 i.e, min(matrix[1][1], matrix[1][2]) * (numbers of elements involved == 2 here). You observe that by sorting each row in descending order we get the following matrix.\n\n[1, 0, 0]\n[2, 1, 1]\n[3, 2, 0]\n\nNow since the row is sorted in descending order we can directly assume that matrix[i][j] is the minimum value so far and we can directly say that the area is (number of elements involved == j+1) * (minimum element so far in the row == matrix[i][j]).\n```\nclass Solution:\n    def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n        m, n, ans = len(matrix), len(matrix[0]), 0\n        \n        for j in range(n):\n            for i in range(1, m):\n                matrix[i][j] += matrix[i-1][j] if matrix[i][j] else 0\n                \n        for i in range(m): \n            matrix[i].sort(reverse=1)\n            for j in range(n):\n                ans = max(ans, (j+1)*matrix[i][j])\n        return ans\n```
['Python3']