Algorithms, Data Structures, DFS, Bfs, Graphs.
function dfs(node, adjList, visited) { if (visited.has(node)) { return; } visited.add(node); for (const neighbour of adjList[node]) { dfs(neighbour, adjList, visited); } } function countConnectedComponents(A, B) { const adjList = buildAdjacencyList(A, B); const visited = new Set(); let