good one
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    public static int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n\n        Map<Integer, Set<Integer>> langSpeakersMap = new HashMap<>();\n\n        for (int i = 0; i < languages.length; i++) {\n            int[] langs = languages[i];\n            for (int lang : langs) {\n                if (langSpeakersMap.get(lang) == null) {\n                    HashSet<Integer> speakersSet = new HashSet<>();\n                    speakersSet.add(i + 1);\n                    langSpeakersMap.put(lang, speakersSet);\n                } else {\n                    langSpeakersMap.get(lang).add(i + 1);\n                }\n            }\n        }\n\n        Set<Integer> usersWhoCannotComEachOther = new HashSet<>();\n\n        for (int[] friendship : friendships) {\n            int user1 = friendship[0];\n            int user2 = friendship[1];\n            boolean found = false;\n            for (int i = 0; i < languages[user1 - 1].length; i++) {//langs spoken by user1\n                int lang = languages[user1 - 1][i];\n                if (langSpeakersMap.get(lang).contains(user2)) {\n                    found = true;\n                    break;\n                }\n            }\n            if (!found) {\n                Collections.addAll(usersWhoCannotComEachOther, user1, user2);\n            }\n        }\n\n        int ans = Integer.MAX_VALUE;\n\n        for (Map.Entry<Integer, Set<Integer>> entry : langSpeakersMap.entrySet()) {\n            Set<Integer> value = entry.getValue();\n            int counter = 0;\n            for (Integer u : usersWhoCannotComEachOther) {\n                if (!value.contains(u)) {\n                    counter++;\n                }\n            }\n            ans = Math.min(ans, counter);\n        }\n\n        return ans;\n    }\n}\n```
['Java']