Simple backtracking java solution
\nclass Solution {    \n    public int calculateNumberOfRows(int [][]mat,Set<Integer> cols){\n        int n=mat.length,m=mat[0].length;\n        int cnt=0;\n   
```\nclass Solution {    \n    public int calculateNumberOfRows(int [][]mat,Set<Integer> cols){\n        int n=mat.length,m=mat[0].length;\n        int cnt=0;\n        int i,j;\n        for(i=0;i<n;i++){\n            for(j=0;j<m;j++) {\n                if(mat[i][j]==1 && !cols.contains(j)) break;\n            }\n            if(j==m) cnt+=1;\n        }\n        return cnt;\n    }\n    public int maximumRows(int[][] mat, int cols,Set<Integer> col,int colNum,int n) {\n        if(cols==0 ){\n            return calculateNumberOfRows(mat,col);            \n        }\n        if(colNum>=n) return Integer.MIN_VALUE;\n        \n        //pick\n        col.add(colNum);\n        int pick=maximumRows(mat,cols-1,col,colNum+1,n);        \n        col.remove(colNum);\n        \n        //not pick\n        int notPick=maximumRows(mat,cols,col,colNum+1,n);                \n        return Math.max(pick,notPick);\n    }\n    public int maximumRows(int[][] mat, int cols) {\n        Set<Integer> col=new HashSet<>();\n        return maximumRows(mat,cols,col,0,mat[0].length);\n    }\n}\n```
['Backtracking', 'Java']