16 line Python solution (998ms)
Intuition\n Describe your first thoughts on how to solve this problem. \nIterate over rows while keeping track of the height of columns of 1\'s above the row. S
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIterate over rows while keeping track of the height of columns of 1\'s above the row. Sort the heights after each iteration and check the area of all possible rectangles that would fit into the graph of heights.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n \\cdot log(n)\\cdot m)$$ with `n = matrix[i].length` and `m = matrix.length`\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$ with `n = matrix[i].length`\n# Code\n```python\nclass Solution:\n    def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n        m = len(matrix) # num rows\n        n = len(matrix[0]) # num cols\n        # The height of a column of 1\'s at a specific index\n        heights = matrix[0].copy()\n        maxArea = heights.count(1)\n        for ri in range(1, m):\n            # Increase or reset height of the column\n            for ci in range(n):\n                if matrix[ri][ci] == 1:\n                    heights[ci] += 1\n                else:\n                    heights[ci] = 0\n            # Bring columns into a "triangle" form, with descending values\n            sortedHeights = sorted(heights.copy(), reverse=True)\n            # Check the area of all possible rectangles inside the imagined triangle\n            for i in range(n):\n                area = sortedHeights[i] * (i+1)\n                if area > maxArea:\n                    maxArea = area\n        return maxArea\n\n```
['Python3']