Simple C++ solution
\n# BFS\n\nclass Solution {\npublic: \n    int findCircleNum(vector<vector<int>> &isConnected){\n        int n=isConnected.size();\n        vector<int> adj[n];\
\n# BFS\n```\nclass Solution {\npublic: \n    int findCircleNum(vector<vector<int>> &isConnected){\n        int n=isConnected.size();\n        vector<int> adj[n];\n        for(int i=0;i<n;i++){\n            for(int j=0;j<n;j++){\n                if(isConnected[i][j]==1){\n                    adj[i].push_back(j);\n                    adj[j].push_back(i);\n                }\n            }\n        }\n        vector<int> visited(n,0);\n        queue<int> q;\n        int res=0;\n        for(int i=0;i<n;i++){\n            if(!visited[i]){\n                visited[i]=1;\n                q.push(i);\n                res++;\n                while(!q.empty()){\n                    int node=q.front();\n                    q.pop();\n                    for(auto adjNode:adj[node]){\n                        if(!visited[adjNode]){\n                            visited[adjNode]=1;\n                            q.push(adjNode);\n                        }\n                    }\n                }\n            }\n        }\n        return res;\n    }\n};\n\n```\n# DFS\n```\nclass Solution {\npublic: \n    void dfs(int node,vector<int> adj[],vector<int> &visited){\n        visited[node]=1;\n        for(auto it:adj[node]){\n            if(!visited[it]){\n                dfs(it,adj,visited);\n            }\n        }\n    }\n    int findCircleNum(vector<vector<int>>& isConnected) {\n        int m=isConnected.size(),n=isConnected[0].size();\n        vector<int> visited(m,0);\n        vector<int> adj[m];\n        for(int i=0;i<m;i++){\n            for(int j=0;j<n;j++){\n                if(isConnected[i][j]==1){\n                    adj[i].push_back(j);\n                    adj[j].push_back(i);\n                }\n            }\n        }\n        int res=0;\n        for(int i=0;i<m;i++){\n            if(!visited[i]){\n                dfs(i,adj,visited);\n                res++;\n            }\n        }\n        return res;\n    }\n};\n\n```
['Depth-First Search', 'Breadth-First Search', 'Graph', 'C++']