C++ || Backtracking || Commented || faster than 100%
For every student try to pair it with every mentor, and for all these combinations, save the maximum resultant.\n\nclass Solution {\npublic:\n    \nvoid find(ve
For every student try to pair it with every mentor, and for all these combinations, save the maximum resultant.\n```\nclass Solution {\npublic:\n    \nvoid find(vector<vector<int> > &students,vector<vector<int >> &mentors,int st,int n,vector<int> &used,int &temp,int &ans)\n{\n    if(st == n)\n    {\n        ans = max(ans,temp);\n        return;\n    }\n    \n    for(int i = 0 ;i < n;i++)\n    {\n        if(used[i] == 0)//got a mentor thats still free, so pair it\n        {\n            used[i] = 1;\n            int score = 0;\n            for(int j = 0 ;j < students[st].size();j++)\n            {\n                if(students[st][j] == mentors[i][j])\n                    score++;\n            }\n            temp += score;//add the score\n            find(students,mentors,st+1,n,used,temp,ans);//recur for remaining students\n            used[i] = 0;//backtrack\n            temp -= score;\n        }\n    }\n}\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {\n        \n        int n = students.size();\n        vector<int> used(n,0);//to keep track of fee mentors\n        int temp = 0;//temp ans for a specific combination\n        int i = 0;//start with the first student\n        int ans = 0;//final ans\n        find(students,mentors,i,n,used,temp,ans);\n        return ans;\n        \n    }\n};\n```\nConsider Upvoting ..!!!!
['Backtracking', 'C++']