PY-35

Compare Two Sets of IDs

  • Easy–Medium
  • Sets and IDs
  • Python

Task

Write compare_id_sets(source_ids, output_ids). Each argument is a list whose IDs are unique within that list. Return one dictionary with exactly these keys: missing, extra, and shared.

  • missing is the set of IDs in source_ids but not output_ids.
  • extra is the set of IDs in output_ids but not source_ids.
  • shared is the set present in both lists.

The dictionary values must all be sets. Neither input list may change.

Example

Input order does not affect the three set values. Two empty lists produce three empty sets.

Your implementation

Edit solution.py and keep this function name and signature:

Return a fresh dictionary containing no keys beyond the three named keys. IDs are hashable, and each input list contains no duplicate ID. Do not mutate either list.