Simple and easy to understand | BFS | Python3 | Beats 80%
Please UpvoteCode
# Please Upvote

# Code
```python3 []
class Solution:
    def numberOfComponents(self, properties: List[List[int]], k: int) -> int:
        n = len(properties)
        m = len(properties[0])
        def intersect(a, b):
            return len(set(a).intersection(set(b)))
        adj = defaultdict(list)
        for i in range(n):
            for j in range(n):
                if i==j:
                    continue
                else:
                    if intersect(properties[i],properties[j])>=k:
                        adj[i].append(j)
        visited = set()
        count = 0
        def bfs(node):
            qu = deque()
            qu.append(node)
            visited.add(node)
            while qu:
                temp = qu.popleft()
                for nei in adj[temp]:
                    if nei not in visited:
                        qu.append(nei)
                        visited.add(nei)
            return
        for i in range(n):
            if i not in visited:
                count+=1
                bfs(i)
        return count

```
['Array', 'Hash Table', 'Breadth-First Search', 'Graph', 'Python3']