Python O(MN log N) with comments
\nfrom collections import Counter\n\nclass Solution:\n    def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n        M = len(matrix)\n        N = len(
```\nfrom collections import Counter\n\nclass Solution:\n    def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n        M = len(matrix)\n        N = len(matrix[0])\n        \n        colcons = [] # preprocess columns\n        for c in range(N):\n            cons = []\n            s = 0\n            for r in range(M):\n                if not matrix[r][c]:\n                    s = 0\n                else:\n                    s += 1\n                cons.append(s)\n            colcons.append(cons)\n        # colcons[c][r] is how much 1\'s we\'ll get if we start from column c at row r and go up\n        \n        best = 0\n        for r in range(M):\n            # try r as the lowest row\n            C = Counter(colcons[c][r] for c in range(N))\n            vs = sorted(C.keys(), reverse=True)\n            cs = accumulate(C[v] for v in vs)\n            for v,c in zip(vs,cs):\n                best = max(best,v*c)\n        return best\n```
['Sorting', 'Python']