Sol in Kotlin
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```\nclass Solution {\n    fun minimumTeachings(n: Int, languages: Array<IntArray>, friendships: Array<IntArray>): Int {\n        val userLanguages = languages.mapIndexed { index, langs -> index + 1 to langs.toSet() }.toMap()\n\n        // Find users who need to be taught\n        val usersToTeach = mutableSetOf<Int>()\n        for ((u1, u2) in friendships) {\n            if (userLanguages[u1]!!.intersect(userLanguages[u2]!!).isEmpty()) {\n                usersToTeach.add(u1)\n                usersToTeach.add(u2)\n            }\n        }\n\n        // Count languages to find the most common one\n        val languageFrequency = mutableMapOf<Int, Int>().withDefault { 0 }\n        for (user in usersToTeach) {\n            for (lang in userLanguages[user]!!) {\n                languageFrequency[lang] = languageFrequency.getValue(lang) + 1\n            }\n        }\n\n        // Find the most common language among users to teach\n        val maxFrequency = languageFrequency.values.maxOrNull() ?: 0\n\n        // Calculate the minimum number of users to teach\n        return usersToTeach.size - maxFrequency\n    }\n}\n```
['Kotlin']