Detect Duplicate Matchups

Hard ⏱ 18 min 30% acceptance ★★★★★ 4.8
A tournament scheduler emits matchups as (team_a, team_b) tuples where ("X", "Y") and ("Y", "X") are the same matchup. Write duplicate_matchups(pairs) returning a sorted list of the matchups (as sorted tuples) that were scheduled more than once.

Examples

Example 1
Input
duplicate_matchups([('X', 'Y'), ('Z', 'W'), ('Y', 'X')])
Output
[('X', 'Y')]
Explanation

('X','Y') and ('Y','X') collide as the same matchup.

Constraints

  • Direction of the pair must not matter.
  • Each duplicate appears once in the output, as a tuple sorted alphabetically.

Topics

Setsfrozensetdeduplication

Companies

Dream11UberMicrosoft

Hints

Hint 1

Normalize each pair to a frozenset (or a sorted tuple) before counting.

Hint 2

Track a seen set and a dupes set while looping.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.