Dsa
Union Find
Easy
Employee Teams
In a company, employees can form teams through collaborations represented by pairs of employee IDs. Your task is to determine how many distinct teams exist after processing all collaborations.
Input Format:
The first line contains an integer t, the number of collaborations. Each of the next t lines contains two integers x and y, representing a partnership between employee x and employee y.
Output Format:
Print the total number of distinct teams formed.
Example:
Input:
4
101 102
102 103
201 202
203 201
Output:
3
Key concepts
union_findcompany_structure
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