✅C++ || EXPLAINED && CLEAN CODE || Pick-NotPick
\n\nwe have to apple pick-notpick on the columns of the matrix and we have to select \'cols\' number of subsequence lets say you selected 0th and 2nd col in the
![image](https://assets.leetcode.com/users/images/30ca8d2a-8c82-46f0-b0dd-862f2f476b1a_1662220873.5870469.png)\n\n***we have to apple pick-notpick on the columns of the matrix and we have to select \'cols\' number of subsequence lets say you selected 0th and 2nd col in the Example -1. Then we have to iterate over rows of the selected columns and have to check weather in a particular row the number of 1\'s is equal to the number of selected columns (in other words whether  all the 1\'s of a particular is covered or not) if all the 1\'s are covered then that row will be counted. and at last we have to take the max count out of it!***\n\n\tclass Solution {\n\tpublic:\n\t\tint maxi=INT_MIN;\n\t\tint n,m;\n\t\tvoid f(int j,vector<int>& ds,vector<vector<int>>& mat,int cols){\n\t\t\tif(ds.size()>cols) return;\n\t\t\tif(j==n){\n\t\t\t\tif(ds.size()==cols){\n\t\t\t\t\tint count=0;\n\t\t\t\t\tfor(int i=0;i<m;i++){\n\t\t\t\t\t\tint sum1=accumulate(mat[i].begin(),mat[i].end(),0);\n\t\t\t\t\t\tint sum2=0;\n\t\t\t\t\t\tfor(auto k:ds){\n\t\t\t\t\t\t\tsum2+=mat[i][k];\n\t\t\t\t\t\t\tif(sum1==sum2){\n\t\t\t\t\t\t\t\tcount++;\n\t\t\t\t\t\t\t\tbreak;    \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tmaxi=max(maxi,count);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t//      Pick\n\t\t\tds.push_back(j);\n\t\t\tf(j+1,ds,mat,cols);\n\t\t\tds.pop_back();\n\t//      NotPick\n\t\t\tf(j+1,ds,mat,cols);\n\t\t}\n\n\t\tint maximumRows(vector<vector<int>>& mat, int cols) {\n\t\t\tn=mat[0].size();\n\t\t\tm=mat.size();\n\t\t\tvector<int> ds;\n\t\t\tf(0,ds,mat,cols);\n\t\t\treturn maxi;\n\t\t}\n\t};
['Backtracking', 'Recursion', 'C', 'C++']