Classify Trophy Rarity Tiers From Unlock Counts
Last updated: November 29, 2026
Quick Overview
Given the number of players who own a game and a map of trophy id to how many of those players earned it, return every trophy with its rarity tier (Ultra Rare under 5%, Very Rare under 15%, Rare under 50%, otherwise Common), sorted rarest first.
PlayStation
November 29, 20260
0
0 solved
Given the number of players who own a game and a map of trophy id to how many of those players earned it, return every trophy with its rarity tier (Ultra Rare under 5%, Very Rare under 15%, Rare under 50%, otherwise Common), sorted rarest first.
Trophy rarity is shown on every PS5 trophy list, so a warm-up question built on it is a natural fit for a PSN backend phone screen. The interviewer checks clean bucketing logic, careful threshold boundaries, and whether you avoid floating point surprises at exact cutoffs.
What the Interviewer Expects
- Clarify whether thresholds are strict or inclusive and how ties sort
- Use integer comparisons (count * 100 < threshold * total) to avoid float boundary bugs
- Handle zero owners and counts larger than the owner total
- Sort by unlock count, then trophy id for a deterministic order
- State O(t log t) time for t trophies
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you keep rarity fresh when millions of unlocks arrive per hour without recomputing everything?
- Should rarity be computed over owners or over players who launched the game at least once? What changes?
- How would you show rarity for a game that launched an hour ago with very few owners?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: total_players (owners of the title) and unlocks: dict[str, int]. Output: a list of (trophy_id, tier, percent) sorted from rarest to most common. Tiers use strict upper bounds: under 5% is...
High-Level Design
For each trophy compute its share and map it to a tier. Instead of count / total < 0.05, compare count * 100 < 5 * total, which is exact with integers. The percent is only computed for display. Th...