Dsa
Union Find
Medium
Team Player Synergy
In a sports league, teams form synergies through player interactions. Each interaction is represented by pairs of team IDs. Your task is to determine how many unique synergies exist after processing all interactions.
Input format:
P
T1 P1
T2 P2
...
TP PT
Where P is the number of interactions and Ti Pi are the pairs of teams that interacted.
Output format:
An integer representing the number of unique synergies.
Example:
Input:
5
1 2
2 3
3 4
5 6
5 7
Output:
3
Key concepts
union_findteamworkcollaboration
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