Dsa
Graphs Dfs
Easy
Team Collaboration
You are given a set of team members represented as a graph where nodes are team members and edges are collaborations. Write a program to find out if a specific member can reach all other members in the team by a series of collaborations. Return 'YES' if they can reach all other members, otherwise return 'NO'.
Input Format:
- The first line contains two integers, N (number of members) and C (number of collaborations).
- The next C lines contain two integers representing the collaborations between two members.
- The last line contains an integer, M, representing the member in question.
Output Format:
- Print 'YES' if the member can reach all other members, otherwise print 'NO'.
Example:
Input:
5 4
1 2
1 3
2 4
3 4
1
Output:
YES
Key concepts
graphsdfssocial network
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