Java Backtracking DFS
\nclass Solution {\n    public int max = 0;\n    public int maxCompatibilitySum(int[][] students, int[][] mentors) {\n        List<Integer> scores = new ArrayLi
```\nclass Solution {\n    public int max = 0;\n    public int maxCompatibilitySum(int[][] students, int[][] mentors) {\n        List<Integer> scores = new ArrayList<>();  \n        boolean[] visited = new boolean[students.length];\n        backtrack(students, mentors, 0, 0, visited);\n        return max;\n    }\n    public void backtrack(int[][] students, int[][] mentors, int ind, int curScore, boolean[] visited) {\n        \n        if (ind == students.length) {\n            max = Math.max(max, curScore);\n            return;\n        }\n        \n        int[] student = students[ind];\n        for (int i = 0; i < mentors.length; i++) {\n            if (visited[i]) {continue;}\n            int comp = getComp(student, mentors[i]);\n            visited[i] = true;\n      \n            backtrack(students, mentors, ind + 1, curScore + comp, visited);\n            visited[i] = false;\n        }\n    }\n    public int getComp(int[] a, int[] b) {\n        int score = 0;\n        for (int i = 0; i < a.length; i++) {\n            if (a[i] == b[i]) {score++;}\n        }\n        return score;\n    }\n    \n    \n}\n```
[]