c++ | easy | short
\nclass Solution {\npublic:\n    int ans=INT_MIN;\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) \n    {\n        int
```\nclass Solution {\npublic:\n    int ans=INT_MIN;\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) \n    {\n        int idx=0;\n        int n=students.size();\n        vector<bool>vis(n,false);\n        int currscore=0;\n        fun(idx,students,mentors,n,vis,currscore);\n        return ans;\n    }               //student        //mentor\n    void fun(int idx,vector<vector<int>>&student,vector<vector<int>>&mentor,int &n,vector<bool>&vis,int currscore)\n    {\n        //base\n        if(idx >= n)\n        {\n            if(currscore > ans)\n            {\n                ans=currscore;\n            }\n            return;\n        }\n        //for the curr ith studen we have the choise for all the mentors\n        //we will try to match the curr student with every mentor individulally\n        //so to avoid the clash in matching we will make that mentor visited after considerration and will run the loop from the starting\n        //we have choise of m mentors\n        for(int i=0;i<n;i++)\n        {\n            if(vis[i]==true)\n            {\n                continue;\n            }\n            else if(vis[i]==false)  //then only we can match the ith student with the curr mentor\n            {\n                vis[i]=true;   //making the curr mentor vis as it got matched now with curr ith student\n                int temp = match(student[idx],mentor[i]);       \t        \t\t\n                fun(idx+1,student,mentor,n,vis,currscore+temp);\n                vis[i]=false;  //backtracking\n            }\n        }\n    }\n    int match(vector<int>&student,vector<int>&mentor)\n    {\n        int n=student.size();\n        int count=0;\n\n        for(int i=0;i<n;i++)\n        {\n            if(student[i]==mentor[i])\n            {\n                count++;\n            }\n        }\n        return count;\n    }\n};\n```
['Dynamic Programming', 'Backtracking', 'Depth-First Search', 'Recursion', 'C', 'C++']