[100% Solution] Concise Solution speeding up with bitmap + Cpp Code
\nRuntime: 120 ms, faster than 100.00% of C++ online submissions \nMemory Usage: 59.2 MB, less than 98.82% of C++ online submissions\n\nWe have N languages and 
```\nRuntime: 120 ms, faster than 100.00% of C++ online submissions \nMemory Usage: 59.2 MB, less than 98.82% of C++ online submissions\n```\nWe have N languages and M persons. Let us image that we have a MxN table "L".\n```\nL[m][n] = 1 means the person m knows the languag n, and 0 means opposite.\n```\nIf two people x, y are friends, we check whether communication is available by evaluate L[x] & L[y] (two rows, O(N) ). If there is no intersection, they should take lessons. However, everybody takes at most one lesson.\n\nFor each language, we check how many guys should be taught (one needs lesson and does\'t know the language).\n\nTotally, it takes:\n1.O(MN) to initialize the table L;\n2.O(FN) to identify people taking lessons. Since F is at most MN, O(FN)<O(MNN)\n3.O(MN) to count the sum of columns of L (where some rows are skipped).\n\nThe Time is max(O(MN), O(FN)), Space is O(MN).\n\n```\nint lesson[500];        //need to take lesson?\nbitset<500> sts[500];   //boost up the process to check whether two friends can communicate\nclass Solution {\npublic:\n    int minimumTeachings(int n, vector<vector<int>>& languages, vector<vector<int>>& friendships) {\n        ios::sync_with_stdio(false);\n        cin.tie(nullptr);\n        int m=languages.size(), ans=INT_MAX;\n        for(int i=0; i<m; ++i) {\n            lesson[i]=0;\n            sts[i].reset();\n            for(auto l:languages[i]) {\n                sts[i].set(l-1);\n            }\n        }\n        for(vector<int> &f:friendships) {\n            if((sts[f[0]-1] & sts[f[1]-1]).none()) {\n                lesson[f[0]-1]=1;\n                lesson[f[1]-1]=1;\n            }\n        }\n        for(int i=0, j, cnt; i<n; ++i) {\n            cnt=0;\n            for(j=0; j<m; ++j) {\n                cnt+=lesson[j] && !sts[j].test(i);\n            }\n            ans=min(ans, cnt);\n        }\n        return ans;\n    }\n};\n```
[]