My simple Dp+Bitmask Memoized Solution--Self Explanatory code
\n\n# Code\n\nclass Solution {\npublic:\nint dp[10][1024];\nint compat(vector<int>&s,vector<int>&m){\n    int res=0;\n    for(int i=0;i<s.size();i++){\n        
\n\n# Code\n```\nclass Solution {\npublic:\nint dp[10][1024];\nint compat(vector<int>&s,vector<int>&m){\n    int res=0;\n    for(int i=0;i<s.size();i++){\n        if(s[i]==m[i])res++;\n    }\n    return res;\n}\nint rec(vector<vector<int>>& students, vector<vector<int>>& mentors,int ind,int mask){\nif(ind>=students.size())return 0;\nif(dp[ind][mask]!=-1)return dp[ind][mask];\nint ans=0;\nfor(int i=0;i<mentors.size();i++){\n    // if mentor is not taken then set the mentor\n    if(( mask &(1<<i))==0){\nint newmask=(mask|(1<<i));\nans=max(ans,compat(students[ind],mentors[i])+rec(students,mentors,ind+1,newmask));\n    }\n\n}\nreturn dp[ind][mask]=ans;\n}\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {\nmemset(dp,-1,sizeof(dp));\n        return rec(students,mentors,0,0);\n    }\n};\n```
['C++']