C++
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 {\npublic:\n    int minimumTeachings(int n,vector<vector<int>>& languages, vector<vector<int>>& friendships) {\n        int m = languages.size();\n        vector<unordered_set<int>> langSet(m + 1);\n\n        for (int i = 0; i < m; ++i) {\n            for (int lang : languages[i]) {\n                langSet[i + 1].insert(lang);\n            }\n        }\n\n        vector<pair<int, int>> needLanguage;\n        for (const auto& friendship : friendships) {\n            int u = friendship[0];\n            int v = friendship[1];\n            if (!haveCommonLanguage(langSet[u], langSet[v])) {\n                needLanguage.push_back({u,v});\n            }\n        }\n\n        if (needLanguage.empty()) {\n            return 0;\n        }\n\n        int minUsers = m;\n        for (int lang = 1; lang <= n; ++lang) {\n            unordered_set<int> usersToTeach;\n            for (const auto& pair : needLanguage) {\n                int u = pair.first;\n                int v = pair.second;\n                if (langSet[u].find(lang) == langSet[u].end()) {\n                    usersToTeach.insert(u);\n                }\n                if (langSet[v].find(lang) == langSet[v].end()) {\n                    usersToTeach.insert(v);\n                }\n            }\n            minUsers = min(minUsers, static_cast<int>(usersToTeach.size()));\n        }\n\n        return minUsers;\n    }\n\nprivate:\n    bool haveCommonLanguage(unordered_set<int>& set1,unordered_set<int>& set2) {\n        for (int lang : set1) {\n            if (set2.count(lang) > 0) {\n                return true;\n            }\n        }\n        return false;\n    }\n};\n\n```
['C++']