C++ | Bitmask
\nclass Solution {\npublic:\n    int maximumRows(vector<vector<int>>& mat, int cols) {\n        int m(size(mat)), n(size(mat[0]));\n        int ans = 0, rows;\n
```\nclass Solution {\npublic:\n    int maximumRows(vector<vector<int>>& mat, int cols) {\n        int m(size(mat)), n(size(mat[0]));\n        int ans = 0, rows;\n        bool flag;\n        for(int mask = 1; mask <= (1<<n); mask++) {\n            if(__builtin_popcount(mask) != cols) continue; \n            vector<int> col_set(n,0);\n            rows = 0;\n            for(int i = 0; i < n; i++) {\n                if(mask & (1<<i)) {\n                    col_set[i] = 1;\n                }\n            }\n            for(int i = 0; i < m; i++) {\n                flag = true;\n                for(int j = 0; j < n; j++) {\n\t                if(!col_set[j] and mat[i][j]) {\n                        flag = false;\n                        break;\n                    }\n                }\n                if(flag) rows += 1;\n            }\n            ans = max(ans,rows);\n        }\n        return ans;\n    }\n};\n```
['C', 'Bitmask']