Dsa
Graphs Dfs
Hard
Central Computer
In a network of computers, each computer is represented as a node, and a direct communication line as an edge. Given an adjacency list and a starting computer, write a program that determines the total number of computers reachable from the starting computer. The input will consist of multiple lines where each line details a node followed by its connected nodes, ending with 'END'. The output should be the count of reachable computers.
Example:
Input:
1 2 3
2 4
3 4
4
5 6
END
1
Output:
4
Key concepts
graphsdfsbfsnetwork
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now