🏆C++ || Easy DFS
Code\n\nclass Solution {\npublic:\n    void dfs(vector<int>&vis,vector<int>ad[],int i){\n        vis[i]=1;\n        for(auto k:ad[i]){\n            if(!vis[k]){
# Code\n```\nclass Solution {\npublic:\n    void dfs(vector<int>&vis,vector<int>ad[],int i){\n        vis[i]=1;\n        for(auto k:ad[i]){\n            if(!vis[k]){\n                dfs(vis,ad,k);\n            }\n        }\n    }\n    int findCircleNum(vector<vector<int>>&g) {\n        int n=g.size();\n        vector<int>ad[n];\n        for(int i=0;i<n;i++){\n            for(int j=0;j<n;j++){\n                if(g[i][j]){\n                    ad[i].push_back(j);\n                    ad[j].push_back(i);\n                }\n            }\n        }\n        int c=0;\n        vector<int>vis(n,0);\n        for(int i=0;i<n;i++){\n            if(!vis[i]){\n                c++;\n                dfs(vis,ad,i);\n            }\n        }\n        return c;\n    }\n};\n```\n![upvote (2).jpg](https://assets.leetcode.com/users/images/5a15a608-89a7-43f3-8415-2bea283c0d9a_1685854017.676268.jpeg)\n
['Depth-First Search', 'Graph', 'C++']