Loading...

The Dictionary Inverter

A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
easy
Seniority
mid

Problem

The metadata service stores tag assignments as {item_id: category}, but downstream consumers need a reverse index that maps each category to all items tagged with it. Write a function that flips a dictionary so each original value becomes a key, mapping to a sorted list of original keys that shared that value.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.