Back to problems

Compute average unique pins per user

Algorithm · Pinterest · Medium

Given a dictionary mapping user identifiers to lists of pin IDs, complete avg_unique_pins(user_to_pins: dict[str, list[int]]) -> float so that it computes the average number of distinct pin IDs per user and returns that value as a float rounded to two decimal places. For each user, count every distinct pin ID in their list once. Treat None entries inside a user's list as invalid and ignore them. If a user's associated value is None or an empty list, that user contributes 0…

Checking your access…