Dsa
Graphs Dfs
Easy
Reachable Nodes Count
Count the number of nodes reachable from a given starting node in a directed graph. The input consists of N (the number of nodes), followed by M edges (directed pairs u, v), and finally a single integer representing the starting node. For example:
5
0 1
1 2
0 3
3 4
1
In this case, the output should be the count of nodes reachable from node 1, which is 2 (nodes 2 and 4).
Key concepts
graphsdfsreachability
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