C++ || Backtracking
\nclass Solution {\npublic:\n    int n,m,ans = 0;\n    void recur(vector<vector<int>>& mat, vector<int>& col_arr, int idx, int remaining_cols){\n        //if we
```\nclass Solution {\npublic:\n    int n,m,ans = 0;\n    void recur(vector<vector<int>>& mat, vector<int>& col_arr, int idx, int remaining_cols){\n        //if we have not selected cols columns then remaining_cols will be non zero and no updatation in ans;\n        if(idx==m and remaining_cols!=0) return;\n        //if we have selected cols columns then we check how many rows satisfies the given condions and update ans\n        if(idx==m and remaining_cols==0){\n           int res = 0;\n            for(int j=0;j<n;j++){\n                bool yes = true;\n                for(int k=0;k<m;k++){\n                    if(mat[j][k] and col_arr[k]==0){\n                        yes = false;\n                        break;\n                    }\n                }\n                if(yes) res++;\n            }\n            ans = max(ans,res);\n            return;\n        }\n        //lets skip this column and recur next\n        recur(mat,col_arr,idx+1,remaining_cols);\n        //or select this column and recur next\n        col_arr[idx] = 1;\n        recur(mat,col_arr,idx+1,remaining_cols-1);\n        col_arr[idx] = 0;\n        return;\n    }\n    \n    int maximumRows(vector<vector<int>>& mat, int cols) {\n        n = mat.size();\n        m = mat[0].size();\n        vector<int>col_arr(m,0);\n        recur(mat,col_arr,0,cols);\n        return ans;\n    }\n};\n```
['Backtracking', 'C']