✅✅Faster || Easy To Understand || C++ Code
This Problem is like Maximum Rectangle In Histogram\n\n Using Sorting\n\n Time Complexity :- O(N * M * logM)\n\n Space Complexity :- O(M)*\n\n\nclass Solution {
* ***This Problem is like Maximum Rectangle In Histogram***\n\n* ***Using Sorting***\n\n* ***Time Complexity :- O(N * M * logM)***\n\n* ***Space Complexity :- O(M)***\n\n```\nclass Solution {\npublic:\n    int largestSubmatrix(vector<vector<int>>& matrix) {\n        \n        int n = matrix.size();\n        \n        int m = matrix[0].size();\n        \n        vector<int> height(m, 0);\n        \n        int max_area = 0;\n        \n        for(int i = 0; i < n; i++)\n        {\n            // update the height array\n            \n            for(int j = 0; j < m; j++)\n            {\n                if(matrix[i][j] == 1)\n                {\n                    height[j]++;\n                }\n                else\n                {\n                    height[j] = 0;\n                }\n            }\n            \n            // sort the height array, because we can rearrange the column\n            \n            vector<int> sorted_height = height;\n            \n            sort(sorted_height.begin(), sorted_height.end());\n            \n            // find the max_area\n            \n            for(int j = 0; j < m; j++)\n            {\n                int curr_area = sorted_height[j] * (m - j);\n                \n                max_area = max(max_area, curr_area);\n            }\n        }\n        \n        return max_area;\n    }\n};\n```
['C', 'Sorting', 'C++']