C++ || Using DFS || T.C : O(N^2) || S.C. : O(V)
\nclass Solution {\n    \n    /*\n        Time Complexity : O(N^2)\n        Space Complexity : O(V)\n    */\n    \nprivate:\n    void dfs(int node, vector<vecto
```\nclass Solution {\n    \n    /*\n        Time Complexity : O(N^2)\n        Space Complexity : O(V)\n    */\n    \nprivate:\n    void dfs(int node, vector<vector<int>> &adj, vector<bool> &visited){\n        visited[node] = true;\n        \n        for(int v : adj[node]){\n            if(!visited[v]){\n                dfs(v, adj, visited);\n            }\n        }\n    }\npublic:\n    int findCircleNum(vector<vector<int>>& isConnected) {\n        int n = isConnected.size();\n        vector<vector<int>> adj(n, vector<int>());\n        \n        for(int i=0; i<n; i++){\n            for(int j=0; j<n; j++){\n                if(i==j) continue;\n                \n                if(isConnected[i][j]){\n                    adj[i].push_back(j);\n                }\n            }\n        }\n        \n        vector<bool> visited(n, false);\n        int count = 0;\n        \n        for(int i=0; i<n; i++){\n            if(!visited[i]){\n                dfs(i, adj, visited);\n                count++;\n            }\n        }\n        \n        return count;\n    }\n};\n```
['Depth-First Search', 'Graph', 'Recursion', 'C++']