Backtracking solution || C++ || Easy to understand
```\nclass Solution {\npublic:\n    int check(vector&student,vector&mentor){\n        int i=0,sum=0;\n        while(i<student.size()){\n            if(student[i
```\nclass Solution {\npublic:\n    int check(vector<int>&student,vector<int>&mentor){\n        int i=0,sum=0;\n        while(i<student.size()){\n            if(student[i]==mentor[i])sum++;\n            i++;\n        }\n        return sum;\n    }\n    void solve(vector<vector<int>>&students,vector<vector<int>>&mentors,int sum,int i, int &max_compat){\n        if(i==students.size()){\n            max_compat=fmax(sum,max_compat);\n            return;\n        }\n        int n=students.size();\n        for(int j=i;j<n;j++){\n            swap(mentors[i],mentors[j]);\n            solve(students,mentors,sum+check(students[i],mentors[i]),i+1,max_compat);\n            swap(mentors[i],mentors[j]);\n        }\n        return;\n    }\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {\n        int max_compat=0;\n        solve(students,mentors,0,0,max_compat);\n        return max_compat;\n    }\n};
['Backtracking', 'C']