A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- easy
- Seniority
- L4
Problem
Given a dict d, return a new dict whose keys are the distinct values of d. Each key's value is a sorted list of original keys that had that value. Return the result as a dict; if the input values are integers they become string keys in the test harness (JSON convention).
Summary
Flip the dict. Group what used to be values.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.