Simple and Intuitive Java Solution | Beats 100%!
Approach\nBacktrack through all possible solutions with length equal to numSelect.\n\nMark visited elements in a boolean array selected and check if the selecte
# Approach\nBacktrack through all possible solutions with length equal to `numSelect`.\n\nMark visited elements in a boolean array `selected` and check if the selected row count exceeds the maximum, when enough elements are selected.\n\n# Code\n```java []\nclass Solution {\n    int maxCount = 0;\n    public int maximumRows(int[][] matrix, int numSelect) {\n        getRows(matrix, numSelect, 0, new boolean[matrix[0].length]);\n        return maxCount;\n    }\n\n    void getRows(int[][] matrix, int numSelect, int idx, boolean[] selected) {\n        if (numSelect == 0) {\n            checkCount(matrix, selected);\n            return;\n        }\n\n        for (int i = idx; i <= matrix[0].length - numSelect; i++) {\n            selected[i] = true;\n            getRows(matrix, numSelect-1, i+1, selected);\n            selected[i] = false;\n        }\n    }\n\n    void checkCount(int[][] matrix, boolean[] selected) {\n        int count = 0;\n        for (int i = 0; i < matrix.length; i++) {\n            boolean isSelected = true;\n            for (int j = 0; j < matrix[0].length; j++) {\n                if (matrix[i][j] == 1 && selected[j] == false) {\n                    isSelected = false;\n                    break;\n                }\n            }\n            if (isSelected) {\n                count++;\n            }\n        }\n\n        maxCount = maxCount < count ? count : maxCount;\n    }\n}\n```
['Backtracking', 'Java']