Implement a Level-Aware Expiring Inventory Store
Company: Optiver
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Take-home Project
Quick Answer: Practice a Optiver coding interview problem focused on implement a level-aware expiring inventory store. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.
Examples
Input: {"operations":[["store","a",1,5,0,None],["retrieve",1]]}
Expected Output: ["a"]
Explanation: Basic retrieval.
Input: {"operations":[["retrieve",1]]}
Expected Output: [""]
Explanation: Empty store.
Input: {"operations":[["store","a",1,5,0,None],["store","b",2,1,0,None],["retrieve",1]]}
Expected Output: ["b"]
Explanation: Higher eligible level wins.
Input: {"operations":[["store","a",1,5,0,None],["store","b",1,9,0,None],["retrieve",1]]}
Expected Output: ["b"]
Explanation: Highest weight on level.
Input: {"operations":[["store","a",1,5,0,2],["retrieve",2]]}
Expected Output: [""]
Explanation: Expired at timestamp 2.
Input: {"operations":[["store","a",1,5,0,10],["store","b",1,9,0,1],["retrieve",2]]}
Expected Output: ["a"]
Explanation: Level still 50 percent active.
Input: {"operations":[["store","a",1,5,0,1],["store","b",1,9,0,1],["retrieve",2]]}
Expected Output: [""]
Explanation: No active items.
Input: {"operations":[["store","a",1,5,0,None],["retrieve",1],["retrieve",2]]}
Expected Output: ["a",""]
Explanation: Retrieved item removed.