Brute force, 94% speed
Runtime: 1352 ms, faster than 93.94%\nMemory Usage: 27.2 MB, less than 59.60%\n\nclass Solution:\n    def minimumTeachings(self, n: int, languages: List[List[in
Runtime: 1352 ms, faster than 93.94%\nMemory Usage: 27.2 MB, less than 59.60%\n```\nclass Solution:\n    def minimumTeachings(self, n: int, languages: List[List[int]], friendships: List[List[int]]) -> int:\n        languages = [set(lst) for lst in languages]\n        incommunicado_friends = set()\n        for friend_1, friend_2 in friendships:\n            if not languages[friend_1 - 1] & languages[friend_2 - 1]:\n                incommunicado_friends.add(friend_1 - 1)\n                incommunicado_friends.add(friend_2 - 1)\n        if not incommunicado_friends:\n            return 0\n        return min(sum(language not in languages[friend]\n                       for friend in incommunicado_friends)\n                   for language in range(1, n + 1))\n```
['Python', 'Python3']