C++ Solution | O(m * n * logn)
\nclass Solution {\npublic:\n\n\tint largestSubmatrix(vector<vector<int>>& a)\n\t{\n\t\tint ans = 0;\n\t\tint n = a.size(), m = a[0].size();\n\n\t\tint tmp[m];\
```\nclass Solution {\npublic:\n\n\tint largestSubmatrix(vector<vector<int>>& a)\n\t{\n\t\tint ans = 0;\n\t\tint n = a.size(), m = a[0].size();\n\n\t\tint tmp[m];\n\t\tmemset(tmp, 0, sizeof(tmp));\n\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tvector<int> v;\n\n\t\t\tfor (int j = 0; j < m; j++)\n\t\t\t{\n\t\t\t\tif (a[i][j] == 1)\n\t\t\t\t{\n\t\t\t\t\ttmp[j] += a[i][j];\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\ttmp[j] = 0;\n\t\t\t\t}\n\t\t\t\tv.push_back(tmp[j]);\n\t\t\t}\n\n\t\t\tsort(v.begin(), v.end());\n\n\t\t\tfor (int j = 0; j < v.size(); j++)\n\t\t\t{\n\t\t\t\tans = max(ans, v[j] * (m - j));\n\t\t\t}\n\t\t}\n\n\t\treturn ans;\n\t}\n};\n```
['Sorting']