[C++] Hash Table, O((M+F)N) Runtime, O(MN) Memory
\nclass Solution {\npublic:\n    int minimumTeachings(int n, vector<vector<int>>& languages, vector<vector<int>>& friendships) {\n        int m = languages.size
```\nclass Solution {\npublic:\n    int minimumTeachings(int n, vector<vector<int>>& languages, vector<vector<int>>& friendships) {\n        int m = languages.size();\n        vector<vector<char>> matrix(m + 1, vector<char>(n + 1, false));\n        for (int i = 0; i < m; i++) {\n            for (const auto& language : languages[i]) {\n                matrix[i + 1][language] = true;\n            }\n        }\n        vector<char> learn(m + 1, false);\n        for (const auto& friendship : friendships) {\n            bool can_communicate = false;\n            for (int i = 1; i <= n; i++) {\n                if (matrix[friendship[0]][i] && matrix[friendship[1]][i]) {\n                    can_communicate = true;\n                    break;\n                }\n            }\n            if (!can_communicate) {\n                learn[friendship[0]] = true;\n                learn[friendship[1]] = true;\n            }\n        }\n        int minimum_learnings = INT_MAX;\n        for (int i = 1; i <= n; i++) {\n            int learnings = 0;\n            for (int j = 1; j <= m; j++) {\n                if (learn[j] && !matrix[j][i]) {\n                    learnings++;\n                }\n            }\n            minimum_learnings = min(minimum_learnings, learnings);\n        }\n        return minimum_learnings;\n    }\n};\n```
['Hash Table', 'Greedy', 'C++']