[Java] simple solution, beats 96.59%
\n\tpublic int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n\t\tint m = languages.length;\n\t\tboolean[][] speak = new boolean[m + 1][n + 
```\n\tpublic int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n\t\tint m = languages.length;\n\t\tboolean[][] speak = new boolean[m + 1][n + 1];\n\t\tboolean[][] teach = new boolean[m + 1][n + 1];\n\t\tfor (int user = 0; user < m; user++) {\n\t\t\tint[] userLanguages = languages[user];\n\t\t\tfor (int language = 0; language < userLanguages.length; language++) {\n\t\t\t\tspeak[user + 1][userLanguages[language]] = true;\n\t\t\t}\n\t\t}\n\t\tList<int[]> listToTeach = new ArrayList<>();\n\t\tfor (int[] friend : friendships) {\n\t\t\tint userA = friend[0];\n\t\t\tint userB = friend[1];\n\t\t\tboolean hasCommonLanguage = false;\n\t\t\tfor (int language = 1; language <= n; language++) {\n\t\t\t\tif (speak[userA][language] && speak[userB][language]) {\n\t\t\t\t\thasCommonLanguage = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!hasCommonLanguage) {\n\t\t\t\tfor (int language = 1; language <= n; language++) {\n\t\t\t\t\tif (!speak[userA][language]) {\n\t\t\t\t\t\tteach[userA][language] = true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!speak[userB][language]) {\n\t\t\t\t\t\tteach[userB][language] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlistToTeach.add(friend);\n\t\t\t}\n\t\t}\n\t\tint minLanguage = Integer.MAX_VALUE;\n\t\tint languageToTeach = 0;\n\t\tfor (int language = 1; language <= n; language++) {\n\t\t\tint count = 0;\n\t\t\tfor (int user = 1; user <= m; user++) {\n\t\t\t\tif (teach[user][language]) {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (count < minLanguage) {\n\t\t\t\tminLanguage = count;\n\t\t\t\tlanguageToTeach = language;\n\t\t\t}\n\t\t}\n\t\tSet<Integer> setToTeach = new HashSet<>();\n\t\tfor (int[] friend : listToTeach) {\n\t\t\tint userA = friend[0];\n\t\t\tint userB = friend[1];\n\t\t\tif (!speak[userA][languageToTeach]) {\n\t\t\t\tsetToTeach.add(userA);\n\t\t\t}\n\t\t\tif (!speak[userB][languageToTeach]) {\n\t\t\t\tsetToTeach.add(userB);\n\t\t\t}\n\t\t}\n\t\treturn setToTeach.size();\n\t}\n```
[]