1733. Minimum Number of People to Teach
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n\n---\n\n```\nvar minimumTeachings = function (n, languages, friends) {\n    const hasIntersection = (lSet, rSet) => {\n        for (const l of lSet) if (rSet.has(l)) return 1;\n        return 0;\n    };\n    const hasNoCommonLanguage = (lSet, rSet) => !hasIntersection(lSet, rSet);\n    const personLanguages = languages.map((arr) => new Set(arr));\n    const uniqueFriendsThatDontSpeakSameLang = new Set();\n    for (let [u, v] of friends) {\n        u--, v--;\n        if (hasNoCommonLanguage(personLanguages[u], personLanguages[v])) {\n            uniqueFriendsThatDontSpeakSameLang.add(u).add(v);\n        }\n    }\n    if (uniqueFriendsThatDontSpeakSameLang.size === 0) return 0;\n    const langFreq = new Map();\n    for (const f of uniqueFriendsThatDontSpeakSameLang)\n        for (const l of personLanguages[f]) {\n            langFreq.set(l, (langFreq.get(l) || 0) + 1);\n        }\n    return uniqueFriendsThatDontSpeakSameLang.size - Math.max(...langFreq.values());\n};\n```\n\n---\n
['JavaScript']