C++ | Simple Next Permutation | No Bit Masking or Back Tracking
The idea is to just try all the combinations of the columns(with maximum cols columns selected) and see how many rows are being covered.\n\nWe can generate all 
The idea is to just try all the combinations of the columns(with maximum ***cols*** columns selected) and see how many rows are being covered.\n\nWe can generate all the permutations using C++ next_permutation() algorithm starting from the first permutation when lexicographically sorted.\n\n\n```\nint maximumRows(vector<vector<int>>& mat, int cols) {\n        int n = mat.size(), m = mat[0].size(), ans=0;\n        vector<int> perm(m,0);\n        // Our initial arrangement should be the first arrangement in the lexicographically sorted permutations.\n        // This helps us to loop over the next_permutations until all the permutations are covered .\n        for(int i=0;i<cols;i++) perm[m-i-1]=1;\n        do {\n            int rows = 0, good;\n            for(int i=0;i<n;i++) {\n                good = 1;\n                for(int j=0;j<m;j++) {\n                    if(mat[i][j]==1 && perm[j]!=1) { \n                        good=0; break; \n                    }\n                }\n                if(good==1) rows++;\n            }\n            ans = max(ans, rows);\n        } while(next_permutation(perm.begin(),perm.end()));\n        \n        return ans;\n    }\n```
['C']