Java detailed solution . Properly documented
\nclass Solution {\n    public int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n        //This is the language map . Key is the person , T
```\nclass Solution {\n    public int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n        //This is the language map . Key is the person , The hashSet is the languages he can speak. We use a hashset to optimize the searching\n        HashMap<Integer,HashSet<Integer>> languageMap = new HashMap<>();\n        \n        //We put the languages known to a map\n        for(int i=0;i<languages.length;i++){\n            \n            languageMap.put(i+1,new HashSet<>());\n            \n            for(int l : languages[i])\n                languageMap.get(i+1).add(l);\n            \n        }\n        \n        //THis is the length of languages matrix\n        int ans = languages.length;\n        \n        //For each language we count the minimum no of people whom we need to teach a particular language i\n        for(int i=1;i<=n;i++){\n            ans = Math.min(ans,num_of_users_to_teach(i,friendships,languageMap));\n        }\n        \n        //The minimum no of people is returned\n        return ans;\n        \n        \n        \n    }\n    //This method counts the minimum no of people to teach a given language lang so that all of them can communicate.\n    private int num_of_users_to_teach(int lang,int[][] friendships,  HashMap<Integer,HashSet<Integer>> languageMap){\n        \n        //We put the unique no of people whom we need to teach languages\n        HashSet<Integer> temp = new HashSet<>();\n        \n        for(int i=0;i<friendships.length;i++){\n            //first and second refers to two persons forming a friendship\n            int first = friendships[i][0];\n            int second = friendships[i][1];\n            //languages spoken by the first user\n            HashSet<Integer> lang_first = languageMap.get(first);\n            //Languages spoken by the second user\n            HashSet<Integer> lang_second = languageMap.get(second);\n            \n            //We first check whether they can communicate which adding this language lang.\n            if(!isCommon(lang_first,lang_second)){\n                //If the language lang is not present in the first persons vocabulary we add it.\n                if(!lang_first.contains(lang))\n                    temp.add(first);\n                //If the language lang is not present in the second  persons vocabulary we add it.\n                if(!lang_second.contains(lang))\n                    temp.add(second);\n                \n            }\n            \n            \n            \n        }\n        \n        return temp.size();\n        \n        \n    }\n    \n    //This method checks whether the communication between two person is possible or not .\n    private boolean isCommon(HashSet<Integer> first,HashSet<Integer> second){\n        \n        for(int k : first){\n            if(second.contains(k))\n                return true;\n        }\n        return false;\n        \n        \n    }\n    \n    \n}\n```
['Java']