Fastest C++ | Beats 100% | Easy and explained 
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
```cpp []
class DisjointSet{
    vector<int>r,p;
public:
    DisjointSet(int n){
        r=vector<int>(n);
        p=vector<int>(n);
        for(int i=0;i<n;i++)p[i]=i;
    }
    int f(int x){
        if(p[x]==x)return x;
        return p[x]=f(p[x]);
    }
    void u(int a,int b){
        a=f(a);b=f(b);
        if(a==b)return;
        if(r[a]<r[b])p[a]=b;
        else if(r[b]<r[a])p[b]=a;
        else p[b]=a,r[a]++;
    }
};

class Solution {
public:
    int numberOfComponents(vector<vector<int>>&A,int k){
        int n=A.size();
        // we can use bitset to find the intersection among all within n^2
        // if we do it using set then it will take n^2*m
        vector<bitset<101>>bs(n);
        for(int i=0;i<n;i++)
            for(int x:A[i])
                bs[i][x]=1;
// Now to find the no.of componets we can use DSU 
        DisjointSet d(n);
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                // Insert all the nodes which have edges
                // Edges are only if there is more than or equal to k common 
                // elements among the 2 vectors
                if((bs[i]&bs[j]).count()>=k)
                    d.u(i,j);
            }
        }
        // simply take a set to find the no.of unqiue ultimate parent 
        unordered_set<int>s;
        for(int i=0;i<n;i++)s.insert(d.f(i));
        // return the size of the set
        return s.size();
    }
};

```
['C++']