Easy and Simple || C++ Solution || DFS || Beginner friendly
the trick here is to convert the given n*n matrix into adjacent matrix and apply the dfs.   \n\'\'\'\n\nclass Solution {\npublic:\n    void dfs(vector<int>adj[]
##### the trick here is to convert the given n*n matrix into adjacent matrix and apply the dfs.   \n\'\'\'\n```\nclass Solution {\npublic:\n    void dfs(vector<int>adj[],vector<bool>&vis,int src){\n        vis[src]=1;\n        for(auto x:adj[src]){\n            if(vis[x]==0)\n                dfs(adj,vis,x);\n        }\n    }\n    int findCircleNum(vector<vector<int>>& v) {\n        int n=v.size();\n        vector<int>adj[n];\n        vector<bool>visited(n,0);\n        for(int i=0;i<n;i++){   // conversion into adjacent matrix\n            for(int j=0;j<n;j++){\n                if(v[i][j]==1)\n                    adj[i].push_back(j);\n            }\n        }\n        int ans=0;\n        for(int i=0;i<n;i++){\n            if(visited[i]==0){\n                ans++;\n                dfs(adj,visited,i);\n            }\n         }\n       return ans;\n    }\n};\n```\nplz upvote if you find this helpful :)\n\'\'\'
['Depth-First Search', 'C', 'C++']