C++ solution
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 public:\n  int minimumTeachings(int n, vector<vector<int>>& languages,\n                       vector<vector<int>>& friendships) {\n    vector<unordered_set<int>> languageSets;\n    unordered_set<int> needTeach;\n    unordered_map<int, int> languageCount;\n\n    for (const vector<int>& language : languages)\n      languageSets.push_back({language.begin(), language.end()});\n\n    // Find friends that can\'t communicate.\n    for (const vector<int>& friendship : friendships) {\n      const int u = friendship[0] - 1;\n      const int v = friendship[1] - 1;\n      if (cantTalk(languageSets, u, v)) {\n        needTeach.insert(u);\n        needTeach.insert(v);\n      }\n    }\n\n    // Find the most popular language.\n    for (const int u : needTeach)\n      for (const int language : languageSets[u])\n        ++languageCount[language];\n\n    // Teach the most popular language to people who don\'t understand.\n    int maxCount = 0;\n    for (const auto& [_, freq] : languageCount)\n      maxCount = max(maxCount, freq);\n\n    return needTeach.size() - maxCount;\n  }\n\n private:\n  // Returns true if u can\'t talk with v.\n  bool cantTalk(const vector<unordered_set<int>>& languageSets, int u, int v) {\n    for (const int language : languageSets[u])\n      if (languageSets[v].count(language))\n        return false;\n    return true;\n  }\n};\n\n```
['C++']