Python(Simple Maths)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minimumTeachings(self, n, languages, friendships):\n        languages = [set(i) for i in languages]\n\n        ans, dict1 = set(), defaultdict(int)\n\n        for i,j in friendships:\n            i = i-1\n            j = j-1\n            if languages[i]&languages[j]: continue\n            ans.add(i)\n            ans.add(j)\n\n        for i in ans:\n            for j in languages[i]:\n                dict1[j] += 1\n\n        return 0 if not ans else len(ans) - max(dict1.values())\n\n```
['Python3']