SIMPLE & EASY JAVA Solution
\nclass Solution {\n\tint ans;\n    public int maxCompatibilitySum(int[][] students, int[][] mentors) {\n        int[][] arr = new int[students.length][students
```\nclass Solution {\n\tint ans;\n    public int maxCompatibilitySum(int[][] students, int[][] mentors) {\n        int[][] arr = new int[students.length][students.length];\n        for(int i = 0; i < students.length; i++) {\n        \tfor(int j = 0; j < mentors.length; j++) {\n        \t\tarr[i][j] = find(students[i], mentors[j]);\n        \t}\n        }\n        ans = 0;\n        boolean[] check = new boolean[mentors.length];\n        pair(0, students.length, check, arr, 0);\n        return ans;\n    }\n    \n    public void pair(int ssf, int tc, boolean[] check, int[][] arr, int sum) {\n    \tif(ssf == tc) {\n    \t\tif(sum > ans)\n    \t\t\tans = sum;\n    \t\treturn;\n    \t}\n    \tfor(int i = 0; i < check.length; i++) {\n    \t\tif(check[i] == false) {\n    \t\t\tcheck[i] = true;\n    \t\t\tpair(ssf + 1, tc, check, arr, sum + arr[ssf][i]);\n    \t\t\tcheck[i] = false;\n    \t\t}\n    \t}\n    }\n    \n    public int find(int[] stu, int[] men) {\n    \tint ans = 0;\n    \tfor(int i = 0; i < stu.length; i++)\n    \t\tif(stu[i] == men[i])\n    \t\t\tans++;\n    \treturn ans;\n    }\n}\n```
['Backtracking', 'Java']