[Java] || Backtracking || Easy to Understand
\t\n\tclass Solution {\n\t\tint max;\n\t\tpublic int maxCompatibilitySum(int[][] students, int[][] mentors) {\n\t\t\tboolean[] visited = new boolean[students.le
\t\n\tclass Solution {\n\t\tint max;\n\t\tpublic int maxCompatibilitySum(int[][] students, int[][] mentors) {\n\t\t\tboolean[] visited = new boolean[students.length];\n\t\t\thelper(visited, students, mentors, 0, 0);\n\t\t\treturn max;\n\t\t}\n\t\tpublic void helper(boolean[] visited, int[][] students, int[][] mentors, int pos, int score){\n\t\t\tif(pos >= students.length){\n\t\t\t\tmax = Math.max(max, score);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor(int i = 0; i < mentors.length; i++)\n\t\t\t\tif(!visited[i]){\n\t\t\t\t\tvisited[i] = true;\n\t\t\t\t\thelper(visited, students, mentors, pos + 1, score + score(students[pos], mentors[i]));\n\t\t\t\t\tvisited[i] = false;\n\t\t\t\t}\n\t\t}\n\t\tpublic int score(int[] a, int[] b){\n\t\t\tint count = 0;\n\n\t\t\tfor(int i = 0; i < b.length; i++)\n\t\t\t\tif(a[i] == b[i]) count += 1;\n\t\t\treturn count;\n\t\t}\n\t}
['Backtracking', 'Java']