Question bank › Union Find
Dsa Union Find Medium

Shared Interests Clusters

A community of people share common interests represented as pairs of IDs. Your task is to find out how many distinct clusters of shared interests there are within the community. Input format: R X1 Y1 X2 Y2 ... XR YR Where R is the number of shared interest pairs between individuals. Output format: An integer representing the number of distinct interest clusters. Example: Input: 5 1 2 2 3 4 5 0 1 0 4 Output: 3

Key concepts

union_findinterestscollectives

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.