Easy Solution - Ashutosh Kumar
Intuition\nThe basic intuition to solve this question is first see that we can only swap columns. This means the vertical order of the 1s doesn\'t change. \n\n#
# Intuition\nThe basic intuition to solve this question is first see that we can only swap columns. This means the vertical order of the 1s doesn\'t change. \n\n# Approach\nWe calculate the no. of consecutive 1s vertically in each row and update the elements according to that. The count resets to 0 whenever we encounter 0. Now we have calculated various base values which means how much 1s are above the base. And the base can contribute its width i.e 1 * height i.e the base value. Now we will sort the rows in non increasing order. Now start count from 1 and traverse left to right in all the rows.\n\nRequired value => ans = max(ans, count*basevalue)\n# Complexity\n- Time complexity:\nAdd your time complexity here, e.g. $$O(m*n)$$\n\n# Space complexity:\nAdd your space complexity here, e.g. $$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int largestSubmatrix(vector<vector<int>>& arr) {\n        int m = arr.size();\n        int n = arr[0].size();\n        for(int j=0;j<n;j++)\n        {\n            for(int i=1;i<m;i++)\n            {\n                if(arr[i][j] == 1)\n                {\n                    arr[i][j] = arr[i-1][j]+1;\n                }\n            }\n        }\n        for(int i=0;i<m;i++)\n        {\n            sort(arr[i].begin(), arr[i].end(), greater<int>());\n        }\n\n        int ans = 0;\n        \n        for(int i=0;i<m;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                ans = max(ans, arr[i][j]*(j+1));\n            }\n        }\n\n        return ans;\n\n    }\n};\n```
['C++']