[C++] || Backtracking
What is Asked ?\n We have to find the maximum rows in which all cells having 1 should be covered by column we picking\n\nHow to Do ?\n\n1. We make a recursive f
**What is Asked ?**\n `We have to find the maximum rows in which all cells having 1 should be covered by column we picking`\n\n**How to Do ?**\n```\n1. We make a recursive function in which we will pick column and not pick it\n2. picking a column means we marked it as visited\n3. When we reached base case we will traverse whole matrix which tells us that\nwhether we can pick a row or not , we can pick a row only when \'1\' s in it are visited which \nwe can verify by visited arrray\n```\n\n**Code**\n```\nclass Solution {\npublic:\n    int maxi = INT_MIN;\n    void helper(vector<vector<int>> &mat , int m , int n , int cols , int idx , vector<int> &vis){\n        if(cols == 0 or idx==n){\n            int cnt = 0;\n            for(int p = 0 ; p < m ; p++){\n                bool check = true;\n                for(int q = 0 ; q < n; q++){\n                    // if cell is 1 and not visited then we cannot take this row\n                    if(mat[p][q] == 1 and vis[q] == 0){\n                        check = false;\n                        break;\n                    }\n                }\n                if(check) cnt++;\n            }\n            maxi = max(maxi,cnt);\n            return;\n        }\n        \n        // picking idx th column and marking column as visited\n        vis[idx]=1;\n        helper(mat,m,n,cols-1,idx+1,vis);\n        vis[idx]=0;\n        \n        // not picking\n        helper(mat,m,n,cols,idx+1,vis);\n        return;\n        \n    }\n    int maximumRows(vector<vector<int>>& mat, int cols) {\n        int m = mat.size();\n        int n = mat[0].size();\n        \n        vector<int> vis(n);\n        \n        helper(mat,m,n,cols,0,vis);\n        return maxi;\n    }\n};\n```
['C']