[Python3] Faster than 100% submissions in time and memory, detailed explanation step by step,
\nclass Solution:\n    def minimumTeachings(self, n: int, languages: List[List[int]], friendships: List[List[int]]) -> int:\n        """\n        1. Find out us
```\nclass Solution:\n    def minimumTeachings(self, n: int, languages: List[List[int]], friendships: List[List[int]]) -> int:\n        """\n        1. Find out users who need to be taught\n        2. If no user needs to be taught, return 0\n        3. For all users who need to be taught a language, find the most popular language among them\n        4. Teach that language to rest of the users who need to be taught. \n        """\n        need_to_be_taught = set()\n        languages = [set(language) for language in languages]\n        \n        # 1. Find out users who needs to be taught\n        for user1, user2 in friendships:\n            # Adjust the 1 based indexing to 0 based indexing\n            user1 = user1 - 1\n            user2 = user2 - 1\n            if not (languages[user1] & languages[user2]):\n                need_to_be_taught.update([user1, user2])\n                \n        # 2. If no user needs to be taught, return 0\n        if not need_to_be_taught:\n            return 0\n        \n        # 3. For all users who needs to be taught a language, find the most popular language among them\n        language_spoken_by = collections.defaultdict(int)\n        for user in need_to_be_taught:\n            # for each user increment the count of languages he can speak\n            for language in languages[user]:\n                language_spoken_by[language] += 1\n    \n        # find occurrence of language spoken by maximum users who can\'t communicate with each other\n        popular_language_count = max(language_spoken_by.values())\n        \n        # 4. Teach that language to rest of the users who need to be taught. \n        return len(need_to_be_taught)- popular_language_count\n        \n        \n        \n                \n```
['Ordered Set', 'Python', 'Python3']