Simple C++ with DFS 
IntuitionApproachComplexity
Time complexity: O(N^2 * M)

Space complexity: O(N^2) + O(N) + O(M)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

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

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

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

# Code
```cpp []
class Solution {
public:
    void dfs(int node,vector<int>adj[],vector<int>&vis)
{
    vis[node]=1;
    for(auto it : adj[node])
        {
            if(!vis[it])
                dfs(it,adj,vis);
        }
}
int fun(vector<int>adj[],int n)
{
    vector<int>vis(n,0);
    int cnt=0;
    for(int i=0;i<n;i++)
        {
            if(!vis[i])
            {
                dfs(i,adj,vis);
                cnt++;
            }
        }
    return cnt;
}

    bool check(vector<int>&a, vector<int>&b,int k,int m)
{
    set<int>st;
    int i=0,j=0;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    while(i<m && j<m)
        {
            if(a[i]==b[j])
            {
                st.insert(a[i]);
                i++;
                j++;
            }
            else if(a[i]<b[j])
            {
                i++;
            }
            else
                j++;
        }
    //cout<<st.size()<<endl;
    return st.size()>=k;
}
    int numberOfComponents(vector<vector<int>>& prop, int k) {
        int n=prop.size();
        vector<int>adj[n];
        int m=prop[0].size();
       // sort(prop.begin(),prop.end());
        for(int i=0;i<n-1;i++)
            {
                for(int j=i+1;j<n;j++)
                    {
                        if(check(prop[i],prop[j],k,m))
                        {
                            adj[i].push_back(j);
                            adj[j].push_back(i);
                        }
                    }
            }

        
        
        return fun(adj,n);
    }
};
```
['Graph', 'Sorting', 'C++']