Java solution 70%
Intuition\n Describe your first thoughts on how to solve this problem. \nThe most complicated part was to understand that it must be one language to solve every
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe most complicated part was to understand that it must be one language to solve everything. \n# Approach\n<!-- Describe your approach to solving the problem. -->\nI decided to create a map of zeros and ones to catch all teach events and then count them in the end. \nStep 1 - We need to find pair with language barrier \nStep 2 - Emulate solving process with each available language (populate teaching map)\nStep 3 - Sum each row in the teaching map to see what language provides better solution \nStep 0 - several times I had to check element existance in an array, I moved this logic into separate method. \n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nNot sure if I calculate correctly but O(n*m + f(x+n+2))\nwhere \nn - number of languages \nm - number of people \nf - number of pairs (friendships)\nx - average number of known languages per person \n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nSpace complaxity is much easier because i didn\'t create a lot of additional objects. \nO(n*m)\n# Code\n```\nclass Solution {\n    public int minimumTeachings(int n, int[][] languages, int[][] friendships) {\n        //create a teaching map\n        int[][] teach = new int[n][languages.length];\n        for(int i=0;i<n;i++)\n            for(int j=0; j<languages.length;j++){\n                teach[i][j]=0;\n            }\n\n        for(int i=0; i<friendships.length;i++){\n            //looking for couples with language barrier \n            boolean flag = false;\n            for(int l=0;l<languages[friendships[i][0]-1].length;l++) {\n                if(findTheElement(languages[friendships[i][1]-1],languages[friendships[i][0]-1][l])){\n                    flag=true;\n                    break;\n                }\n                else\n                    flag=false;\n            }\n            //fill in teaching map with all languages per friend\n            if(!flag){\n                for(int j=1;j<=n; j++){\n                    for(int k: friendships[i]){\n                        if(teach[j-1][k-1]==0)\n                            if(!findTheElement(languages[k-1],j)){\n                                teach[j-1][k-1] = 1;\n                            }\n                    }\n                }\n            }\n        }\n        //min is equal m, this is the case when all people speak one language\n        int min=languages.length;\n        for(int[] i:teach){\n            int sum=0;\n            for(int j: i){\n                sum+=j;\n            }\n            if(sum<min)\n                min=sum;\n        }\n        return min;\n    }\n\n\n    private boolean findTheElement(int[] array1, int n){\n        for(int i: array1){\n            if(i==n)\n                return true;\n        }\n        return false;\n    }\n}\n```
['Array', 'Java']