Dfs || Easy to Understand || C++
\n\nclass Solution {\npublic:\n    void dfs(int node,vector<bool> &vis, vector<int> adj[]){\n        vis[node]=1;\n        for(auto it=adj[node].begin();it!=adj
\n```\nclass Solution {\npublic:\n    void dfs(int node,vector<bool> &vis, vector<int> adj[]){\n        vis[node]=1;\n        for(auto it=adj[node].begin();it!=adj[node].end();it++){\n            if(!vis[*it]){\n                dfs(*it,vis,adj);\n            }\n        }\n    }\n    int findCircleNum(vector<vector<int>>& arr) {\n        int n=arr.size();\n        vector<bool> vis(n,0);\n        vector<int> adj[n];\n        for(int i=0;i<n;i++){\n            int m=arr[i].size();\n            for(int j=0;j<m;j++){\n                if(arr[i][j]==1){\n                    adj[i].push_back(j);\n                }\n                \n            }\n        }\n\n        int ans=0;\n        for(int i=0;i<n;i++){\n            if(!vis[i]){\n                ans++;\n                dfs(i,vis,adj);\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']