Question bank › Union Find
Dsa Union Find Easy

Event Participation Groups

In an events management system, users can sign up for events. If two users sign up for the same event, they belong to the same participation group. Write a program to determine how many distinct participation groups exist after processing all sign-ups. Input format: - The first line contains an integer n (1 ≤ n ≤ 1000), the number of users. - The second line contains an integer e (0 ≤ e ≤ 10000), the number of events. - The following e lines contain pairs (a, b) representing that user a and user b signed up for the same event. Output format: - Output a single integer, the number of distinct participation groups. Example: Input: 4 4 0 1 1 2 2 3 0 3 Output: 1

Key concepts

union_findnetwork

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.