TLE Issue Solution using minor changes
Approach
Steps to solve tle issue;
1.
instead of this:do this:2.
instead of this:do this:Complexity
Time complexity:

Space complexity:
Code
# Approach
<!-- Describe your approach to solving the problem. -->
> ## **Steps to solve tle issue;**

$$1.$$
instead of this:
```
for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
        adj[i].push_back(j);
    }
}
```
do this:
```
for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
        adj[i].push_back(j);
        adj[j].push_back(i);
    }
}
```

$$2.$$
instead of this:
```
int intersect(vector<int>&arr1, vector<int>&arr2){
    unordered_set<int>hash1(arr1.begin(), arr1.end());
    unordered_set<int>hash2(arr2.begin(), arr2.end());
    int count = 0;
    for(auto it: hash2){
        if(hash1.find(it)!=hash1.end()) count++;
    }
    return count;
}
```
do this:
```
int intersect(vector<int>&arr1, vector<int>&arr2){
    unordered_set<int>hash1(arr1.begin(), arr1.end());
    int count = 0;
    for(auto it: arr2){
        if(hash1.find(it)!=hash1.end()){
            hash1.erase(it);
            count++;
        } 
    }
    return count;
}
```
# 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:
    int intersect(vector<int>&arr1, vector<int>&arr2){
        unordered_set<int>hash1(arr1.begin(), arr1.end());

        int count = 0;
        for(auto it: arr2){
            if(hash1.find(it)!=hash1.end()){
                hash1.erase(it);
                count++;
            } 
        }
        return count;
    }
    void bfs(int node, vector<int>&vis, vector<vector<int>>&adj){
        queue<int>q;
        vis[node] = 1;

        q.push(node);

        while(!q.empty()){
            int currNode = q.front();
            q.pop();

            for(auto it: adj[currNode]){
                if(!vis[it]){
                    vis[it] = 1;
                    q.push(it);
                }
            }
        }
    }

    int numberOfComponents(vector<vector<int>>& properties, int k) {
        int n = properties.size();

        vector<vector<int>>adj(n);
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                if(i!=j){
                    if( intersect(properties[i], properties[j]) >= k){
                        adj[i].push_back(j);
                        adj[j].push_back(i);
                    }

                }
            }
        }

        vector<int>vis(n,0);
        int count = 0;
        for(int i=0; i<n; i++){
            if(!vis[i]){
                bfs(i,vis,adj);
                count++;
            }
        }

        return count;
    }
};
```
['Depth-First Search', 'Breadth-First Search', 'Graph', 'Ordered Set', 'C++']