Intiution & Explanation with code & comments, beats 100% C++
To find the language to be taught to minimum number of people in real life, we can call the number of people who cant communicate with atleast one of their frie
To find the language to be taught to minimum number of people in real life, we can call the number of people who cant communicate with atleast one of their friend and of all of them can vote what is the most popular language among them, and those who dont know (minority)  will learn it\n```\nclass Solution {\npublic:\n    bool checkinvalid( int a, int b, vector<vector<int>>& languages){ //helper func., checks if a and b can communicate or not\n        a--; b--;\n        for( int i=0;i<languages[a].size();i++){\n            if(find(languages[b].begin(), languages[b].end(), languages[a][i]) != languages[b].end()) return false;\n        }\n        return true;\n    }\n    \n    int minimumTeachings(int n, vector<vector<int>>& languages, vector<vector<int>>& friendships) {        \n        int m= languages.size();\n        vector<vector<int>> g(m+1, vector<int>(0)); // graph to store adjacency list with people as nodes & friendships as edges\n        // create graph\n        for( int i=0;i<friendships.size();i++){\n            g[friendships[i][0]].push_back(friendships[i][1]);\n            g[friendships[i][1]].push_back(friendships[i][0]);\n        }\n        \n        vector<int> voters(m+1,0); // to store people who cant communicate with atleast a friend\n        int voterscount=0; \n        for( int i=1;i<m+1;i++){\n             for( int j=0;j<g[i].size();j++){\n                if( checkinvalid(i, g[i][j], languages)){ // ith can vote\n                    voters[i]=1;\n                    voterscount++;\n                    break;\n                }\n            }\n        }\n        unordered_map<int,int> mappy; //  language -> votes\n        int maxvotes=0; \n        \n        for( int i=1;i<m+1;i++){\n            if(voters[i]==1){ \n                for( int j: languages[i-1]){\n                    mappy[j]++;\n                    \n                    if(maxvotes<mappy[j]){\n                        maxvotes= mappy[j];\n                    }\n                }\n            }\n        }\n        return voterscount - maxvotes; // # who need to be taught the language\n    }\n};\n```\n
['C']