count for friends without same language  c++
\nclass Solution {\n    bool hassame(const vector<int>& v1, const vector<int>& v2)\n    {\n        int i1=0, i2=0;\n        while(i1<v1.size() && i2<v2.size())\
```\nclass Solution {\n    bool hassame(const vector<int>& v1, const vector<int>& v2)\n    {\n        int i1=0, i2=0;\n        while(i1<v1.size() && i2<v2.size())\n        {\n            if (v1[i1] == v2[i2])\n                return true;\n            else if (v1[i1] < v2[i2])\n                i1++;\n            else\n                i2++;\n        }\n        return false;\n    }\npublic:\n    int minimumTeachings(int n, vector<vector<int>>& languages, vector<vector<int>>& friendships) {\n        int m = languages.size();\n        int k = friendships.size();\n        for(auto& l: languages)\n            sort(l.begin(), l.end());\n        vector<bool> candidates(m, false);\n        for(int i=0; i<k; i++)\n        {\n            auto i1 = friendships[i][0] - 1, i2 = friendships[i][1] - 1;\n            if (!hassame(languages[i1],languages[i2]))\n                candidates[i1] = candidates[i2] = true;\n        }\n        vector<int> count(n, 0);\n        int candidate_count = 0;\n        for(int i=0; i<m; i++)\n        {\n            if (candidates[i])\n            {\n                candidate_count++;\n                for(int j=0; j<languages[i].size(); j++)\n                    count[languages[i][j]-1]++;\n            }\n        }\n        return candidate_count - *max_element(count.begin(), count.end());\n    }\n};\n```
[]