Implement Game Metadata Lookups
Company: Discord
Role: Data Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Onsite
Quick Answer: This question evaluates in-memory data modeling, search and aggregation over structured records, case-insensitive string handling, and counting unique platform entries.
Constraints
- 0 <= len(games) <= 100000
- 0 <= len(queries) <= 100000
- Each game name is unique case-insensitively
- Each game record contains at least: name, release_date, platform, genre, and publisher
- platform is a list of strings and may contain duplicates
- Returned game-name lists must preserve the order in which games appeared in the input
Examples
Input: ([{'name': 'Cyber Quest', 'release_date': '2025-01-01', 'platform': ['playstation', 'xbox'], 'genre': 'RPG', 'publisher': 'GameStudio A'}, {'name': 'Battle Arena', 'release_date': '2024-11-15', 'platform': ['pc'], 'genre': 'Action', 'publisher': 'GameStudio B'}, {'name': 'Sky Adventure', 'release_date': '2025-02-10', 'platform': ['playstation'], 'genre': 'Adventure', 'publisher': 'GameStudio A'}, {'name': 'Mystery World', 'release_date': '2023-07-20', 'platform': ['xbox', 'pc'], 'genre': 'Puzzle', 'publisher': 'GameStudio C'}, {'name': 'Speed Racer', 'release_date': '2025-03-05', 'platform': ['pc', 'playstation'], 'genre': 'Racing', 'publisher': 'GameStudio B'}], [('get_genre', 'cyber quest'), ('get_games', 'rpg'), ('get_games', 'ACTION'), ('get_most_available_games',), ('get_available_games', 1), ('get_genre', 'Unknown Game')])
Expected Output: ['RPG', ['Cyber Quest'], ['Battle Arena'], ['Cyber Quest', 'Mystery World', 'Speed Racer'], ['Battle Arena', 'Sky Adventure'], None]
Explanation: Lookups are case-insensitive. Three games have the maximum of 2 unique platforms. Battle Arena and Sky Adventure are each available on exactly 1 unique platform.
Input: ([{'name': 'Echo Drift', 'release_date': '2024-01-01', 'platform': ['pc', 'pc', 'xbox'], 'genre': 'Racing', 'publisher': 'Studio One', 'country': 'US', 'discord_servers': ['echo-hub']}, {'name': 'Puzzle Box', 'release_date': '2024-02-01', 'platform': ['switch'], 'genre': 'Puzzle', 'publisher': 'Studio Two'}, {'name': 'Silent Echo', 'release_date': '2024-03-01', 'platform': ['pc', 'xbox'], 'genre': 'racing', 'publisher': 'Studio Three'}], [('get_available_games', 2), ('get_most_available_games',), ('get_games', 'RACING'), ('get_genre', 'silent echo')])
Expected Output: [['Echo Drift', 'Silent Echo'], ['Echo Drift', 'Silent Echo'], ['Echo Drift', 'Silent Echo'], 'racing']
Explanation: Duplicate platforms are counted once, so Echo Drift has 2 unique platforms. Genre lookup for RACING matches both Racing and racing.
Hints
- Build dictionaries keyed by lowercased or casefolded names and genres so lookups are O(1) on average.
- Precompute each game's unique platform count once, then index games by that count and track the maximum count.