C++ Solution | Easy Implementation
\nint largestSubmatrix(vector<vector<int>>& matrix) {\n        \n        int i, j, ans = 0, n = matrix.size(), m = matrix[0].size();\n        \n        for(i = 
```\nint largestSubmatrix(vector<vector<int>>& matrix) {\n        \n        int i, j, ans = 0, n = matrix.size(), m = matrix[0].size();\n        \n        for(i = 0; i < m; i++)\n        {\n            for(j = 1; j < n; j++)\n            {\n                if(matrix[j][i] == 1)\n                    matrix[j][i] = matrix[j-1][i] + matrix[j][i];\n                else\n                    matrix[j][i] = 0;\n            }\n        }\n\n        for(i = 0; i < n; i++)\n        {\n            sort(matrix[i].begin(), matrix[i].end(), greater<int>());\n\n            for(j = 0; j < m; j++)\n                ans = max(ans, matrix[i][j] * (j + 1));\n        }\n        \n        return ans;\n    }\n```\n\nSolution:\n\n* Convert the matrix so that Matrix[i][j] is the sum of continous 1\'s upto ith row in the column number j.\n* If the element in that cell is 1 add it to the previous streak else make it 0.\n* Then find the maximum area upto ith row. To do this first sort the ith row in descending order.\n* Now minimum upto jth column * (j+1) will be the area, the maximum of all these is the final answer.\n\nFirst step is shown in the picture:\n\n![image](https://assets.leetcode.com/users/images/e42dc0e6-6681-4448-882d-d0f9935076bc_1610855910.3583114.png)  **To**  ![image](https://assets.leetcode.com/users/images/f0773c9c-bec4-45e6-9dc0-0b4693495e7c_1610855922.829031.png)\n\nIf you are having problem in visualizing the solution please have a look at this article:\nhttps://leetcode.com/problems/largest-submatrix-with-rearrangements/discuss/1020710/C%2B%2B-Clean-and-Clear-With-Intuitive-Pictures-O(m-*-n-*-logn)\n
[]