[C++] count 1s and then sort
\nclass Solution {\npublic:\n    int largestSubmatrix(vector<vector<int>>& matrix) {\n        int m = matrix.size(), n = matrix[0].size();\n        vector<vecto
```\nclass Solution {\npublic:\n    int largestSubmatrix(vector<vector<int>>& matrix) {\n        int m = matrix.size(), n = matrix[0].size();\n        vector<vector<int>> cntOne(m, vector<int>(n, 0));\n        for (int j = 0; j < n; j++) {\n            if (matrix[0][j] == 1) {cntOne[0][j] = 1;}\n        }\n        for (int i = 1; i < m; i++) {\n            for (int j = 0; j < n; j++) {\n                if (matrix[i][j] == 0) {cntOne[i][j] = 0;}\n                else {cntOne[i][j] = cntOne[i - 1][j] + 1;}\n            }\n        }\n        \n        int ans = 0;\n        for (int i = 0; i < m; i++) {\n            vector<int> curr = cntOne[i];\n            sort(curr.begin(), curr.end(), greater());\n            for (int j = 0; j < n; j++) {\n                ans = max(ans, curr[j] * (j + 1));\n            }\n        }\n        return ans;\n    }\n};\n```
['C', 'Sorting']