Easiest solution using java
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {

    int intersect(int[] A, int[] B){
        Set<Integer> set = new HashSet<>();
        int count = 0;
        for(int x : A) set.add(x);
        for(int x : B){
            if(set.contains(x)){
                count++;
                set.remove(x);
            }
        }
        return count;
    }

    public void dfs(List<Integer> [] graph, int start, boolean[] vis){

        vis[start] = true;
        for(int curr: graph[start]){
            if(!vis[curr]){
                dfs(graph, curr, vis);
            }
        }
    }
    public int numberOfComponents(int[][] p, int k) {

        int n = p.length;

        List<Integer> [] graph = new List[n];
        for(int i = 0; i<n;i++) graph[i] = new ArrayList<>();
        
        for(int i = 0; i<p.length; i++){
            for(int j = i+1; j<p.length; j++){
                if(intersect(p[i], p[j]) >= k){
                    System.out.println("hell");
                    graph[i].add(j);
                    graph[j].add(i);
                }
            }
        }

        int ans = 0;

        boolean[] vis = new boolean[n];

        for(int i = 0; i<n;i++){
            if(!vis[i]){
                dfs(graph, i, vis);
                ans++;
            }
        }

        return ans;
    }
}
```
['Java']