Beats 95% simple prefix sum like solution
Intuition\n Describe your first thoughts on how to solve this problem. \ncount the continuous ones on each column for each row and sort them in descending order
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ncount the continuous ones on each column for each row and sort them in descending order so that the first column contains the most number of continuous ones. Sorting so that we can align the ones continuously to make it a submatrix. \n\n**this line may confuse you: ans=max(ans,temp[j]*(j+1)); use a note and pen to make it clear**\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFor each row find the number of continuos ones by adding the previous rows ones , then sort them so that the ones are aligned continuously\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(M*N*log(N))\n    M->number of rows\n    N->number of columns \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(M*N)\n# Code\n```\nclass Solution {\npublic:\n    int largestSubmatrix(vector<vector<int>>& mat) {\n        ios::sync_with_stdio(0);cout.tie(0);cin.tie(0);\n        int r=mat.size(),c=mat[0].size();\n        int ans=0;\n        for(int i=0;i<r;i++){\n            for(int j=0;j<c;j++){\n                if(mat[i][j]!=0 and i!=0)\n                mat[i][j]+=mat[i-1][j];\n            }\n            vector<int>temp=mat[i];\n            sort(temp.begin(),temp.end(),greater());\n            for(int j=0;j<c;j++){\n                ans=max(ans,temp[j]*(j+1));\n            }\n        }\n        return ans;\n    }\n};\n```
['Greedy', 'Sorting', 'Prefix Sum', 'C++']