Backtracking + Recursive Approach with Detail Explanation || Beginner Friendly
Code\n\nclass Solution {\n    int max;\n\n    private void solveBacktrack(int[][] students, int[][] mentors, int pos, int score, boolean[] vis) {\n        // Ba
# Code\n```\nclass Solution {\n    int max;\n\n    private void solveBacktrack(int[][] students, int[][] mentors, int pos, int score, boolean[] vis) {\n        // Base Case\n        if (pos >= students.length) {\n            max = Math.max(max, score);\n            return;\n        }\n\n        // Recursive Approach Start....\n        for (int i = 0; i < mentors.length; i++) {\n            if (!vis[i]){\n                vis[i] = true;\n                solveBacktrack(students, mentors, pos + 1, score + helper(students[pos], mentors[i]), vis);\n\n                // BackTrack....\n                vis[i] = false;\n            }\n        }\n    }\n\n    private int helper(int[] student, int[] mentor) {\n        int count = 0;\n        for (int i = 0; i < mentor.length; i++) {\n            if (student[i] == mentor[i])\n                count++;\n        }\n        return count;\n    }\n\n    public int maxCompatibilitySum(int[][] students, int[][] mentors) {\n        boolean[] vis = new boolean[students.length];\n        solveBacktrack(students, mentors, 0, 0, vis);\n        return max;\n    }\n}\n```
['Array', 'Dynamic Programming', 'Backtracking', 'Bit Manipulation', 'Recursion', 'Bitmask', 'Java']