Java Solution with comments
Iterate all the friendships to find the pair that don\'t have common lanagues\n2. If they don\'t have common lanagues, then check if this person is already in t
1. Iterate all the friendships to find the pair that don\'t have common lanagues\n2. If they don\'t have common lanagues, then check if this person is already in the set or not\n3. If it\'s not then add the lanagues of that person to the count array.\n4. Greedy choose the max languages (this is the languages for the friends that don\'t have common languages)\n```\nclass Solution {\n    public int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n        int[] count=new int[n+1]; \n        Set<Integer> set=new HashSet<Integer>();\n        for(int i=0;i<friendships.length;i++){\n            int u=friendships[i][0];\n            int v=friendships[i][1];\n            int[] l1=languages[u-1];\n            int[] l2=languages[v-1];\n            Arrays.sort(l1);\n            Arrays.sort(l2);\n            int ll1=0;\n            int ll2=0;\n            boolean flag=false;\n            while(ll1<l1.length&&ll2<l2.length){\n                if(l1[ll1]==l2[ll2]){\n                    flag=true;\n                    break;\n                }else if(l1[ll1]<l2[ll2]){\n                    ll1++;\n                }else{\n                    ll2++;\n                }\n            }\n            if(!flag){\n                if(!set.contains(u)){\n                    for(ll1=0;ll1<l1.length;ll1++){\n                        count[l1[ll1]]++;\n                    }\n                    set.add(u);\n                }\n                \n                if(!set.contains(v)){\n                    for(ll2=0;ll2<l2.length;ll2++){\n                        count[l2[ll2]]++;\n                    }\n                    set.add(v);\n                }              \n            }\n        }        \n        int max=0;\n        for(int i=1;i<=n;i++){\n            max=Math.max(max, count[i]);\n        }\n        return set.size()-max;\n    }\n}``\n```
[]