C++ | unordered_set
\nclass Solution {\npublic:\n    int minimumTeachings(int n, vector<vector<int>>& lng, vector<vector<int>>& frnd) {\n        unordered_set<int> unc;\n        in
```\nclass Solution {\npublic:\n    int minimumTeachings(int n, vector<vector<int>>& lng, vector<vector<int>>& frnd) {\n        unordered_set<int> unc;\n        int lsz=lng.size();\n        int fsz=frnd.size();\n        vector<unordered_set<int>> v(lsz+1);\n        for(int i=0;i<lsz;i++){\n            unordered_set<int> temp;\n            for(auto n:lng[i])\n                temp.insert(n);\n            v[i+1]=temp;\n        }\n        \n        for(int i=0;i<fsz;i++){\n            unordered_set<int>& a=v[frnd[i][0]],b=v[frnd[i][1]];\n            bool yes=0;\n            for(auto n:a){\n                if(b.count(n)) {yes=1;break;}\n            }\n            if(!yes){\n                unc.insert(frnd[i][0]);\n                unc.insert(frnd[i][1]);\n            }\n        }\n        unordered_map<int,int> mp;\n        int ans=0;\n        for(auto n:unc){\n            unordered_set<int> a=v[n];\n            \n            for(auto n:a)\n            {\n                mp[n]++;\n                ans=max(ans,mp[n]);\n            }\n        }\n        return unc.size()-ans;\n    }\n};\n```
['C', 'C++']