This question evaluates a candidate's ability to process collections and compute aggregated metrics, including per-user deduplication of items, handling of missing/null entries, numeric averaging and rounding.
You are given a mapping from user IDs to their lists of pin IDs. Implement a function that computes the mean number of unique pin IDs per user.
avg_unique_pins(user_to_pins: dict[str, list[int]]) -> float
None
values within lists.
Input: {"user1": [1, 2, 2], "user2": [1, 2, 3]} → Output: 2.50
0.00
.
None
).
Login required