C++ || solution
\nclass Solution {\npublic:\n    int bits(int n)\n    {\n        int count = 0;\n        while (n) {\n            n =n& (n - 1);\n            count++;\n        
```\nclass Solution {\npublic:\n    int bits(int n)\n    {\n        int count = 0;\n        while (n) {\n            n =n& (n - 1);\n            count++;\n        }\n        return count;\n    }\n    int binexp(int x,int n){\n        int a=x;\n        int prod=1;\n        while(n)\n        {\n            if(n%2==1)prod=prod*a;\n            a=a*a;\n            n=n/2;\n        }\n        return prod;\n    }\n    int maximumRows(vector<vector<int>>& mat, int cols) {\n        int m=mat.size();\n        int n=mat[0].size();\n        int res=0;\n        \n        for(int i=0;i<binexp(2,n);i++)\n        {\n            if(bits(i)==cols)\n            {\n                vector<int> v(n,0);\n                int x=i;\n                for(int i=0;i<n;i++)\n                {\n                    v[i]=x%2;\n                    x/=2;\n                }\n                int count=0;\n                for(int j=0;j<m;j++)\n                {\n                    bool check=true;\n                    for(int k=0;k<n;k++)\n                    {\n                        if(mat[j][k]==1 && v[k]==0)\n                        {\n                            check=false;break;\n                        }\n                    }\n                    if(check) count++;\n                    \n                }\n                res=max(res,count);\n            }\n        }\n        return res;\n    }\n};\n```
[]