Question bank › Union Find
Dsa Union Find Hard

Team Formation

In a company, there are employees who can form teams based on mutual connections. You will receive pairs of employee IDs that indicate a connection between two employees. Your task is to find the size of the largest team that can be formed based on the connections. An employee can be part of multiple connections but is only counted once in a team. Input Format: The first line contains an integer n (number of employees). The second line contains an integer m (number of connections). The next m lines contain pairs of integers u and v, representing a connection between employee u and employee v. Output Format: Print the size of the largest team. Example: Input: 5 4 1 2 2 3 4 5 1 4 Output: 4

Key concepts

union_finddisjoint_setmerging

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.