Easy DSU Approach
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 Solution {
public:
    vector<int>parent,rank;
    void init(int n){
        parent.resize(n+1);
        rank.resize(n+1);
        for(int i=0;i<parent.size();i++)parent[i]=i;
    }
    int find(int u){
        if(u==parent[u])return u;
        return parent[u]=find(parent[u]);
    }
    void unionbyrank(int u,int v){
        int up=find(u);
        int uv=find(v);
        parent[uv]=up;
    }
    bool can(unordered_set<int>&a,unordered_set<int>&b,int k){
        int cnt=0;
        for(auto i:a){
            if(b.find(i)!=b.end())cnt++;
            if(cnt==k)return 1;
        }return 0;
    }
    int numberOfComponents(vector<vector<int>>& properties, int k) {
        init(properties.size());
        vector<unordered_set<int>>st(properties.size());
        for(int i=0;i<properties.size();i++){
            unordered_set<int>sp;
            for(auto j:properties[i])sp.insert(j);
            st[i]=sp;
        }
        for(int i=0;i<properties.size();i++){
            for(int j=0;j<i;j++){
                if(i==j)continue;
                if(can(st[i],st[j],k)){
                    unionbyrank(i,j);
                }
            }
        }
        unordered_set<int>st2;
        for(int i=0;i<properties.size();i++){
            st2.insert(find(i));
        }return st2.size();
    }
};
```
['Union Find', 'Graph', 'Ordered Set', 'C++']