Using Recursion 
IntuitionHere you need to understand that you can link any of the student to any of the mentor and explore all the posibilities to get max scoreApproachI hope y
# Intuition
Here you need to understand that you can link any of the student to any of the mentor and explore all the posibilities to get max score

# Approach
I hope you already know recursion & dynamic programming !

Loop through all the students

One student at a time and try all possiblities of mentors... 

Consider i=0, 0th index student linked to one mentor randomly and count score then next 

Consider i=1, now linked any other mentor to 1th index student randomly... 

keep this going on...

Through recursion find max scores in all possiblities

# Complexity
- Time complexity:
2^n since it is recursion 

- Space complexity:
O(n^2)

# Code
```java []
class Solution {
    public int maxCompatibilitySum(int[][] students, int[][] mentors) {
        boolean menVis[] = new boolean[mentors.length];
        int n = students.length;
        return f(n-1,students,mentors,menVis);
    }
    public static int f(int i,int[][] students,int[][] mentors,boolean[] menVis){
        if(i<0) return 0;
        int max = 0;
        for(int j=0;j<menVis.length;j++){
            if(menVis[j]==false){
                menVis[j]=true;
                int points = 0 ;
                for(int k=0;k<mentors[j].length;k++){
                    if(students[i][k]==mentors[j][k]) points++;
                }
                int sum = points+f(i-1,students,mentors,menVis);
                menVis[j]=false;
                max = Math.max(sum,max);
            }
        }
        return max;
    }
}

['Dynamic Programming', 'Recursion', 'Java']