Java Simple and easy to understand solution, clean code with comments
\nclass Solution {\n    int maxScoreSum;\n    \n    public int maxCompatibilitySum(int[][] students, int[][] mentors) {\n        int s = students.length;\n     
```\nclass Solution {\n    int maxScoreSum;\n    \n    public int maxCompatibilitySum(int[][] students, int[][] mentors) {\n        int s = students.length;\n        int m = mentors.length;\n        \n        //store the cores of each pair of students and mentors\n        int[][] scores = new int[s][m];\n        \n        for(int i = 0; i < s; i++){\n            for(int j = 0; j < m; j++){\n                scores[i][j] = getScore(students[i], mentors[j]);\n            }\n        }\n        \n        maxScoreSum  = 0; \n        \n        \n        //try every permutation of mentonr and student\n        backtracking(scores, new boolean[m], 0, 0);\n        \n        \n        return maxScoreSum;\n    }\n    \n    private void backtracking(int[][] scores, boolean[] used, int index, int sum){\n        \n        if(index == scores.length){\n            maxScoreSum = Math.max(maxScoreSum, sum);\n            return;\n        }\n        \n        \n        for(int i = 0; i <  scores[0].length; i++){\n            if(used[i]) continue;\n            \n            used[i] = true;\n            \n            backtracking(scores, used, index + 1, sum + scores[index][i]);\n            \n            used[i] = false;\n            \n        }\n                \n                \n    }\n    \n    private int getScore(int[] student, int[] mentor){\n        int score = 0;\n        \n        for(int i = 0; i < mentor.length; i++){\n            if(student[i] == mentor[i]) {\n                score ++;\n            }\n        }\n        \n        return score;\n    }\n}\n```
['Backtracking', 'Java']