Dsa
Union Find
Medium
Conference Attendee Clusters
During a conference, attendees form connections through discussions. Each connection is represented by pairs of attendee IDs. Compute the number of clusters formed by attendees who have at least one connection with others.
Input format:
K
A1 B1
A2 B2
...
AK BK
Where K is the number of connections between attendees.
Output format:
An integer representing the number of attendee clusters.
Example:
Input:
4
1 2
2 3
3 4
5 6
Output:
2
Key concepts
union_findnetworkingevents
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