Question bank › Union Find
Dsa Union Find Easy

Team Collaboration Network

Consider a team of employees in a company where each employee can collaborate with others through a series of connections. Given the number of employees and their collaboration connections, determine if two specified employees can work together. Input starts with two integers N (number of employees) and M (collaboration pairs). Follow this with M lines of pairs indicating collaboration. In the last line, specify two employees. Print 'YES' if they can collaborate, else print 'NO'. Example Input: 4 4 1 2 2 3 3 1 4 2 3 4 Output: YES

Key concepts

union_findcollaborationnetwork

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.