Backtracking | Easy to Understand
Code
# Code
```cpp []
class Solution {
    int cal_max_score(vector<vector<int>> &scores, int i = 0){
        static unordered_set<int> used_mentors ;
        if(i >= scores.size()) return 0 ;
        int res = 0 ;
        for(int j = 0 ; j < scores[i].size() ; j++){
            if(used_mentors.find(j) != used_mentors.end()) continue ;
            used_mentors.insert(j) ;
            int curr = scores[i][j] ;
            res = max(res,curr+cal_max_score(scores,i+1)) ;
            used_mentors.erase(j) ;
        }
        return res ;
    }
public:
    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {
        int n = students.size() ;
        vector<vector<int>> scores(n,vector<int>(n,0)) ;
        
        // generate student - mentor score values
        for(int s = 0 ; s < n ; s++){
            for(int m = 0 ; m < n ; m++){
                for(int j = 0 ; j < students[0].size() ; j++){                        
                    scores[s][m] += students[s][j] == mentors[m][j] ;
                }
            }
        }

        // try every student - mentor combination
        return cal_max_score(scores) ;
    }
};
```
['Backtracking', 'C++']