Unique solution || bests 100% || Well Expalined and easy to understand
\n# Approach\n\n\n1. Iterate through the matrix, updating each element to represent the height of consecutive 1s above it.\n2. Sort the heights of each row in a
\n# Approach\n\n\n1. Iterate through the matrix, updating each element to represent the height of consecutive 1s above it.\n2. Sort the heights of each row in ascending order.\n3. Iterate through each row, calculating the area for each height and width combination, updating the maximum area encountered.\n4. Return the maximum area found during the iteration, representing the largest submatrix of consecutive 1s.\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] == 1){\n                    matrix[i][j]+=matrix[i-1][j];\n                }\n            }\n        }\n        int ans = 0;\n        for(int i = 0;i<n;i++){\n            sort(matrix[i].begin(), matrix[i].end());\n\n            for(int j=0;j<m;j++){\n                int h = matrix[i][j];\n                int w = m-j;\n                ans = max(ans, h*w);\n            }\n        }\n        return ans;\n    }\n};\n```
['Sorting', 'C++']