C++ 🔥 || Beginner Friendly ⛳️ || DFS ⛳️ || 100% 🎯
\uD83D\uDD25 Donn Forget to Upvote if you liked the Approach. \uD83D\uDD25\n\n# Approach\nThe Problem is nothing but a variation to find no. of connected compon
### \uD83D\uDD25 Donn Forget to Upvote if you liked the Approach. \uD83D\uDD25\n\n# Approach\n**The Problem is nothing but a variation to find no. of connected components of a graph.**\n\nApproach is quite simple we\'ll firstly structure the graph the apply DFS to all unvisited nodes while marking them 1.\n\nEach time when we\'ll call a unvisited node we\'ll increase our count by 1 and then we\'ll visit all the nodes connected with that node.\n\nIn the end we\'ll return the total count that will be our answer.\n\n\n\n# Code\n```\nclass Solution {\npublic:\n    int visited[205];\n    void check(vector<int> v[],int itr)\n    {\n        if(visited[itr]) \n            return;\n// Visiting all the connected nodes with our called node.\n        visited[itr]=1;\n        for(int i=0;i<v[itr].size();i++)\n            check(v,v[itr][i]);\n\n        return;\n    }\n\n\n    int findCircleNum(vector<vector<int>>& isConnected) {\n        int ans=0; // This is our count.\n        vector<int> v[isConnected.size()];\n// Structuring the Graph.\n        for(int i=0;i<isConnected.size();i++)\n            for(int j=0;j<isConnected[i].size();j++)\n                if(isConnected[i][j])v[i].push_back(j);\n// Calling the unvisited Nodes.\n        for(int i=0;i<isConnected.size();i++)\n            if(!visited[i])\n            {\n                check(v,i);\n                ans++;\n            }\n        return ans;\n    }\n};\n```
['Depth-First Search', 'Union Find', 'Graph', 'C++']