O(en) time, O(v + n) space
Approach\n1. Find the friends who aren\'t able to communicate with someone\n2. Find the most common language among them\n3. Teach that to the rest of them \n\n#
# Approach\n1. Find the friends who aren\'t able to communicate with someone\n2. Find the most common language among them\n3. Teach that to the rest of them \n\n# Complexity\n- Time complexity: O(en), where e is the number of edges and n is the number of languages\n\n- Space complexity: O(v + n), where v is the number of vertices and n is the number of languages\n\n# Code\n```\nclass Solution:\n    def minimumTeachings(self, n: int, languages: List[List[int]], friendships: List[List[int]]) -> int:\n        students = set()\n        for (u, v) in friendships:\n            if not set(languages[u - 1]) & set(languages[v - 1]):\n                students.add(u)\n                students.add(v)\n        lang_counts = [0 for _ in range(n + 1)]\n        for student in students:\n            for lang in languages[student - 1]:\n                lang_counts[lang] += 1\n        return len(students) - max(lang_counts)\n        \n```
['Python3']