C++ simple dp solution
\n\n\nclass Solution {\npublic:\n   int dp[10];\n    int comp(vector<vector<int>>& students, vector<vector<int>>& mentors,int i,int j){\n        int k,l,count=0
\n\n```\nclass Solution {\npublic:\n   int dp[10];\n    int comp(vector<vector<int>>& students, vector<vector<int>>& mentors,int i,int j){\n        int k,l,count=0;\n        for( k=0;k<students[i].size();k++){\n            if(students[i][k]==mentors[j][k])\n                count++;\n        }\n        return count;\n    }\n    int find(vector<vector<int>>& students, vector<vector<int>>& mentors,int ind){\n        if(ind==students.size())\n            return 0;\n        int ans=-1;\n       \n         for(int j=0;j<students.size();j++){\n         if(dp[j]==0){\n             dp[j]=1;\n            ans=max(comp(students,mentors,ind,j)+find(students,mentors,ind+1),ans);\n             dp[j]=0;\n             }\n         }\n         return ans;\n    }\n    int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {\n         return find(students,mentors,0);\n        \n    }\n};\n```
[]