Simple greedy approach || Not a medium level question probably hard one 🤨
\nclass Solution\n{\n    public:\n        int largestSubmatrix(vector<vector < int>> &mat)\n        {\n            int m = mat.size();\n            int n = mat[
```\nclass Solution\n{\n    public:\n        int largestSubmatrix(vector<vector < int>> &mat)\n        {\n            int m = mat.size();\n            int n = mat[0].size();\n            vector<int> h(n, 0);//array for counting height at each level.\n            vector<int> x;\n            int ans = 0;\n            for (int i = 0; i < m; i++)//iterating at every level.\n            {\n                for (int j = 0; j < n; j++)\n                {\n                    if (mat[i][j] == 0)// if cuurent height is 0 then discard the previously stored .height.\n                        h[j] = 0;\n                    else\n                        h[j] += 1;// increment the height if it is continuous.\n                }\n                x = h;\n                sort(x.begin(), x.end(), greater<int> ());//sort and calculate max area.\n                int curr = 0;\n                int height = INT_MAX;\n                for (int j = 0; j < n; j++)\n                {\n                    height = min(height, x[j]);\n                    curr = max(curr, height *(j + 1));\n                }\n                ans = max(ans, curr);\n            }\n            return ans;\n        }\n};\n```
['Math', 'Greedy', 'C', 'Sorting']