C++ | BFS Approach
\n    int findCircleNum(vector<vector<int>>& isConnected) {\n        \n        int n = isConnected.size(), provinces = 0;\n        vector<int> adj[n + 1], vis(n
```\n    int findCircleNum(vector<vector<int>>& isConnected) {\n        \n        int n = isConnected.size(), provinces = 0;\n        vector<int> adj[n + 1], vis(n + 1, 0);\n        \n        for(int i = 0; i < n; i++) \n            for(int j = 0; j < n; j++)\n                if(isConnected[i][j] == 1 && i != j) \n                    adj[i + 1].push_back(j + 1);\n        \n        for(int i = 1; i <= n; i++) {\n            if(!vis[i]) {\n                provinces++;\n                queue<int> q;\n                q.push(i);\n                vis[i] = 1;\n                while(q.size()) {\n                    int node = q.front();\n                    q.pop();\n                    for(auto it : adj[node]) if(!vis[it]) { q.push(it); vis[it] = 1; }\n                }\n            }\n        }\n        return provinces;\n    }\n```
[]