1733. Minimum Number of People to Teach.cpp
Code\n\nclass Solution {\npublic:\n    bool findCommon(vector<int>&a, vector<int>&b) {\n        for(int i=0;i<a.size();i++) {\n            for(int j=0;j<b.size(
**Code**\n```\nclass Solution {\npublic:\n    bool findCommon(vector<int>&a, vector<int>&b) {\n        for(int i=0;i<a.size();i++) {\n            for(int j=0;j<b.size();j++) {\n                if(a[i]==b[j])\n                    return 1;\n            }\n        }\n        return 0;\n    }    \n    int minimumTeachings(int n, vector<vector<int>>& lang, vector<vector<int>>& friends) {\n        int l = lang.size();\n        int f = friends.size();\n        set<int> ppl_with_no_common; \n        unordered_map<int,vector<int>> mp ;         \n        for(int i=0;i<f;i++) {\n            if(!findCommon(lang[friends[i][0]-1] , lang[friends[i][1]-1])) \n            {\n                ppl_with_no_common.insert(friends[i][0]);\n                ppl_with_no_common.insert(friends[i][1]);\n            }\n        }        \n        for(int j=0;j<l;j++) {\n            if(ppl_with_no_common.find(j+1)!=ppl_with_no_common.end()) {\n                for(int k=0;k<lang[j].size();k++)            \n                    mp[lang[j][k]].push_back(j+1);\n            }\n        }\n        int ans = 0;\n        int language = 0;\n        for(int i=1;i<=mp.size();i++) {\n            if(ans<mp[i].size()) {\n                ans = mp[i].size();\n                language = i;\n            }\n        }\n        return ppl_with_no_common.size()-ans;\n    }\n};\n```
['C']