Java solution with explanation
\n\nclass Solution {\n    \n    /**\n    Algorithm:\n\n        1. We will initialize the variable \'minimumUsers\' = total users, and it will store the minimum 
\n```\nclass Solution {\n    \n    /**\n    Algorithm:\n\n        1. We will initialize the variable \'minimumUsers\' = total users, and it will store the minimum number of users that needs to learn the common language.\n        2. Maintain a user Map, which stores users who cannot communicate with their friends.\n            Check if users \'user1\' and \'user2\' shares a common language.\n            If both users do not share a common language, then insert both users in the Map.\n        3. Iterate thru the list of languages,\n            We will set the variable \'totalUsers\' as 0, which will store the total number of users need to learn a common languge.\n            Iterate it over the user MAP\n                Check if the user at it cannot speak a language, then increment \'totalUsers\' by 1.\n            If \'minimumUsers\' is more than \'totalUsers\', then update \'minimumUsers\' with \'totalUsers\'.\n        4. Return the variable \'minimumUsers\'.\n\nTime Complexity: O(NxM)\n\t* \tN: number of languages\n\t* \tM: number of users\nSpace Complexity: O(NxM)\n    **/\n    \n    \n    public int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n\n        //minimumUsers first start with all users\n        //and will be updated to store the minimum number of users to teach\n        int minimumUsers = friendships.length;\n        \n        //Map to store User and the Languagues that user can speak. \n        Map<Integer,Set<Integer>> user_languages = new HashMap<>();\n        for(int user = 0; user < languages.length; user++) {\n            Set<Integer> lst_languages = new HashSet<>();\n            for(int language = 0; language < languages[user].length; language++) {\n                lst_languages.add(languages[user][language]);\n            }\n            user_languages.put(user+1, lst_languages); //user+1 because the no. of users start with 1 rather than 0\n        }\n                        \n        //Map to store User and the his friends who he cant communicate with. \n        Map<Integer,Set<Integer>> user_friends = new HashMap<>();\n        for(int i = 0; i < friendships.length; i++){\n            int[] friends = friendships[i];\n            int user1 = friends[0];\n            int user2 = friends[1];\n\n            if(!canCommunicate(user_languages.get(user1), user_languages.get(user2))) {\n                //store user1 \n                user_friends.putIfAbsent(user1, new HashSet<>());\n                user_friends.get(user1).add(user2);\n\n                //store user2 \n                user_friends.putIfAbsent(user2, new HashSet<>());\n                user_friends.get(user2).add(user1);\n            }\n           \n        }\n\n        //loop thru every language and check to see if a user need to learn a common langue\n        for(int language = 1; language <= n; language++) {\n            //the variable \'totalUsers\' as 0, \n            //which will store the total number of users needs to learn a common language\n            int totalUsers = 0;\n            for(int user : user_friends.keySet()) {\n                if(!user_languages.get(user).contains(language)) {\n                    totalUsers++;\n                } \n            }    \n            minimumUsers = Math.min(minimumUsers,totalUsers);\n        }    \n        return minimumUsers;\n        \n    }\n    \n    private boolean canCommunicate(Set<Integer> user1_languages, Set<Integer> user2_languages) {\n        for(int user2_language : user2_languages){\n            if(user1_languages.contains(user2_language)){\n                return true;\n            }\n        }\n        return false;\n    }\n}\n```
[]