Simple C++ solution || TC: O(nmlog(m)) || SC:O(1)
Intuition\nThis code finds the largest submatrix with all 1s in a binary matrix. It first transforms the matrix to represent the height of \'buildings\' of 1s. 
# Intuition\nThis code finds the largest submatrix with all 1s in a binary matrix. It first transforms the matrix to represent the height of \'buildings\' of 1s. Then, for each row, it calculates the maximum area of the rectangle that can be formed using the \'building\' at each cell as the shortest \'building\'. The maximum of these areas is the result.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nThis code is a solution to a problem where we need to find the largest submatrix with all 1s in a given binary matrix. The approach used in this code is dynamic programming and sorting.\n\nHere\'s a step-by-step breakdown of the approach:\n\n1. **Preprocessing**: For each cell in the matrix, if the cell value is not `0`, add the value of the cell just above it to the current cell. This step transforms the matrix such that each cell now contains the height of the \'building\' at that cell, i.e., the number of consecutive `1`s above that cell including itself.\n\n2. **Finding Maximum Area**: For each row in the matrix, sort the elements in non-increasing order. Then, for each cell in the row, calculate the area of the rectangle that can be formed using the \'building\' at that cell as the shortest \'building\'. The area is calculated as the product of the height of the shortest \'building\' and the number of \'buildings\'. Update the maximum area if the calculated area is greater.\n\n3. **Final Result**: If the maximum area remains as `INT_MIN`, it means there are no `1`s in the matrix, so return `0`. Otherwise, return the maximum area.\n\nThis approach ensures that we consider all possible submatrices of `1`s and choose the one with the maximum area. The use of dynamic programming helps to avoid redundant calculations and improves the efficiency of the solution. \n\n# Complexity\n- Time complexity: O(nmlog(m))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int largestSubmatrix(vector<vector<int>>& matrix) {\n        int n=matrix.size();\n        int m=matrix[0].size();\n        for(int i=1; i<n; i++){\n            for(int j=0; j<m; j++){\n                if(matrix[i][j]!=0)matrix[i][j]+=matrix[i-1][j];\n            }\n        }\n        int maxarea=INT_MIN;\n        for(int i=0; i<n; i++){\n            sort(matrix[i].begin(), matrix[i].end(),greater<int>());\n            int temp=INT_MAX;\n            for(int j=0; j<m; j++){\n                if(matrix[i][j]==0)continue;\n                temp=min(temp,matrix[i][j]);\n                int area=(j+1)*temp;\n                maxarea=max(maxarea,area);\n            }\n        }\n        if(maxarea==INT_MIN)return 0;\n        return maxarea;\n    }\n};\n```
['C++']