simple intuitive approach .beats 78 perc . o(n2) .
Approachfirst we will sort all the arrays in properties and remove their duplicates.
then we will take 2 arrays and check if their intersection ( ie common uniq


# Approach
first we will sort all the arrays in properties and remove their duplicates.
then we will take 2 arrays and check if their intersection ( ie common unique elements) is greater than k.
to do this we have used a 2 pointers approach.
if intersection comes out to be greater than k .we form an undirected edge between node i and node j.
for this we are maintaining an adjacency list g.
then we apply dfs.
we traverse over all nodes.if it is unvisited we visit that node and all its neighbours and their neighbours...recursively and color them with their component no.
in the end we return no of components.


# Complexity
- Time complexity:
o(n2)



# Code
```cpp []
class Solution {
public:
    int intersect(vector<int>a,vector<int>b)
    {
        int i=0,j=0;
        int ct=0;
       while(i<a.size() && j<b.size()){
                if(a[i]==b[j])
                {
                    ct++;
                    i++;
                    j++;

                }
                else if(a[i]<b[j])
                {
                    i++;
                }
                else
                j++;
            }
    //  cout<<ct;
        return ct;
    }
    void dfs(vector<vector<int>>&g,int i,int compno,vector<int>&vis)
    {
        vis[i]=compno;

        for(auto u:g[i])
        {
            if(vis[u]==0)
                {
                    dfs(g,u,compno,vis);
                }
        }
    }
    int numberOfComponents(vector<vector<int>>& properties, int k) {
    vector<vector<int>>g;
    int n=properties.size();
    g.resize(n);
        for(int i=0;i<n;i++)
        {
              sort(properties[i].begin(),properties[i].end());
               properties[i].erase(unique(properties[i].begin(),properties[i].end()),properties[i].end());
//for(auto u: properties[i])
//cout<<u<<" ";

cout<<endl;
      
        }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int ic=(intersect(properties[i],properties[j]));
             if(ic>=k)
                {
                   // cout<<"between "<<i<<"and "<<j<<" intersection : "<<k<<endl;
                    g[i].push_back(j);
                    g[j].push_back(i);
                }
           
        }
    }
    vector<int>vis(n,0);
    int compno=0;
        for(int i=0;i<n;i++)
        {
            if(vis[i]==0)
            {
                compno++;
                dfs(g,i,compno,vis);
            }
        }
        return compno;
    }
};
```
['C++']