Easy explained with best approach|| C++||greedy
Intuition\nIntution is the precomputation of cells find the height for every column in the subsequent array.Then sorting of row according in non decreasing orde
# Intuition\nIntution is the precomputation of cells find the height for every column in the subsequent array.Then sorting of row according in non decreasing order and calculating the area since the cell number would provide the height and take width for subsequent column.\n\n# Approach\n1.precomputation\n2. for any row ith (for every jth column) matrix[i][j]=matrix[i-1][j]+1 only if matrix[i][j]=1.\n3. Traverse through each row sort it using sort(itr.begin(),itr.end())\n   and traverse the whole row (from last since to find max)\n   output the maximum ans by computing area as  itr[k]*w   where\n   itr[k] defines the height and w width which increases by 1 at \n   subsequent steps.\n \n# Complexity\n- Time complexity:\nO(m*n*log(n)) is the time complexity.\n\n- Space complexity\n- O(1) constant space is used.\n\n# Code\n```\nclass Solution {\npublic:\n    int largestSubmatrix(vector<vector<int>>& matrix) {\n        int m=matrix.size();\n        int n=matrix[0].size();\n        for(int i=1;i<m;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                if(matrix[i][j]==1)\n                {\n                    matrix[i][j]=matrix[i-1][j]+1;\n                }\n            }\n        }\n        int ans=0;\n        for(auto itr:matrix)\n        {\n            sort(itr.begin(),itr.end());\n    \n            for(int k=n-1,w=1;k>=0 && itr[k]>0;k--,w++)\n            {   \n                int area=itr[k]*w;\n                ans=max(ans,area);\n            }\n        }\n        return ans;\n        //  0 0 1\n        //  1 1 2\n        //  2 0 3\n\n        //  0 0 1\n        //  1 1 2\n        //  0 2 3\n    }\n};\n```
['Math', 'Greedy', 'Sorting', 'Matrix', 'C++']