easy to understand, good for novice
Intuitionbrute force each language, see which one has the least people to teach.Complexity
Time complexity:
O(n*m)Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
brute force each language, see which one has the least people to teach.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(n*m)
# Code
```python3 []
class Solution:
    def minimumTeachings(self, n: int, languages: List[List[int]], friendships: List[List[int]]) -> int:
        all_lang=set()
        for item in languages:
            for lang in item:
                if lang not in all_lang:
                    all_lang.add(lang)
        
        def check_need(languages,friendships):
            np=len(languages)
            result=[True]*np
            for relation in friendships:
                a=relation[0]
                b=relation[1]
                lan_a=languages[a-1]
                lan_b=languages[b-1]
                if len(set(lan_a) & set(lan_b))==0:
                    result[a-1]=False
                    result[b-1]=False
            return result

        result=check_need(languages,friendships)
        
        mincount=float('inf')
        np=len(languages)
        for lang in all_lang:
            count=0
            for p in range(np):
                lan=languages[p]
                if not result[p]:
                    if lang not in lan:
                        count+=1
            mincount=min(mincount,count)
        return mincount



            

            
            




        
```
['Python3']