Nobody Else Has It

Python for AIHard+10 XP+10

Nobody Else Has It

A sticker-swap club wants to know which stickers are rare. groups is a list with one entry per collector, and each entry is a list of the stickers they own (with repeats).

Task: write unique_to_each(groups). Return a list with one entry per collector, in the same order. Each entry is a list, sorted alphabetically, of the stickers that only that collector owns — nobody else in groups has one.

  • A collector with nothing rare gets [].
  • If groups is empty, return [].

Examples

groups = [["cat", "dog", "owl"], ["dog", "fox"], ["owl", "bee", "bee"]]
returns [['cat'], ['fox'], ['bee']]
groups = []
returns []

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run