Simple || DFS || Beginner Friendly || Counting ✅🎯
Approach:dfs(u, vis, adj):
Standard depth-first search (DFS) to traverse connected components in an adjacency list representation of a graph.
Marks visited node
# Approach:
## dfs(u, vis, adj):

- Standard depth-first search (DFS) to traverse connected components in an adjacency list representation of a graph.
- Marks visited nodes to avoid reprocessing.
## intersect(a, b):

- Uses two binary arrays (one and two) of size 101 to track the presence of numbers in arrays a and b.
- Checks how many indices have 1 in both arrays (i.e., common distinct integers).

## numberOfComponents(properties, k)

- Graph Construction: Creates an adjacency list where edges are added if two properties share at least k common elements.

- Connected Component Counting: Uses DFS to count the number of connected components in the graph.

# Code
```cpp []
class Solution {
public:
    void dfs(int u,vector<bool>& vis,unordered_map<int,vector<int>>& adj){
        vis[u]=true;
        for(int &v:adj[u]){
            if(!vis[v]) dfs(v,vis,adj);
        }
    }
    int intersect(vector<int>& a,vector<int>& b){
        int cnt=0;
        vector<int>one(100+1,0);
        vector<int>two(100+1,0);
        for(int &x:a) one[x]=1;
        for(int &x:b) two[x]=1;
        for(int i=1;i<=100;i++) cnt+=one[i]&two[i];
        return cnt;
    }
    int numberOfComponents(vector<vector<int>>& properties, int k) {
        unordered_map<int,vector<int>> adj;
        int n=properties.size();
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(intersect(properties[i], properties[j])>=k){
                    adj[i].push_back(j);
                    adj[j].push_back(i);
                }
            }
        }
        int res=0;
        vector<bool>vis(n,false);
        for(int i=0;i<n;i++){
            if(!vis[i]){
                dfs(i,vis,adj);
                res++;
            }
        }
        return res;
    }
};
```
['Array', 'Hash Table', 'Depth-First Search', 'Graph', 'Counting', 'C++']