Time-Based Key-Value Database
Reported by candidates from Illumio's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Illumio reported this one in July 2025, and it looks like a design question but it's really a hash map plus a binary search. You're building a time-based key-value store that handles SET and GET operations in order, and every GET wants the latest value at or before a timestamp. If you've seen the classic LeetCode version, you're already ahead. If you haven't, the shape is simple once you see it. StealthCoder sits invisible on your screen as a safety net if you blank mid-assessment, but the idea fits in your head tonight.
The problem
Process operations on a time-based key-value database. Each operation is one of: ["SET", key, value, timestamp]: store value for key at the integer timestamp. ["GET", key, timestamp]: return the value stored for key at the greatest timestamp less than or equal to the requested timestamp. Return the empty string when no such value exists. SET timestamps are strictly increasing for each individual key. GET timestamps may arrive in any order. Return one string for every GET operation, in operation order. Function runTimeDatabase(operations: String[][]) → String[] Examples Example 1 operations = [["SET","foo","bar","1"],["GET","foo","1"],["GET","foo","3"],["SET","foo","bar2","4"],["GET","foo","4"],["GET","foo","5"]] return = ["bar","bar","bar2","bar2"] The first two reads use the value stored at timestamp 1. Once bar2 is stored at timestamp 4, reads at 4 and later return it. Example 2 operations = [["GET","missing","2"],["SET","a","one","3"],["SET","b","two","5"],["GET","a","2"],["GET","a","10"],["GET","b","5"]] return = ["","","one","two"] A missing key and a query before a key's first timestamp both return the empty string. Keys keep independent histories. Constraints 1 <= operations.length <= 20000 Every operation has a valid name and arity. Keys and stored values are non-empty strings. 0 <= timestamp <= 10^9 SET timestamps are strictly increasing for each key.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Here's what it reduces to: a hash map from key to a list of (timestamp, value) pairs. Because SET timestamps are strictly increasing per key, each list stays sorted just by appending. No re-sorting, no tree needed. For GET, binary search the key's list for the rightmost timestamp less than or equal to the query. Return that value, or an empty string if the key is missing or every stored timestamp is larger. The common pitfall is scanning linearly, which can be slow with 20000 operations. Another is off-by-one on the search bound. Remember that a GET at exactly the stored timestamp must match, so use an upper-bound search and step back one. Also, collect outputs only for GET operations, in order. Timestamps arrive as strings, so parse them to integers before comparing. If you freeze live, StealthCoder can hand you the skeleton while you verify the edge cases.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Time-Based Key-Value Database cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as time based key value store. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Illumio's OA.
Illumio reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Time-Based Key-Value Database FAQ
What's the trick in the Illumio time-based key-value database problem?+
Store a sorted list of (timestamp, value) per key in a hash map. SET timestamps are strictly increasing per key, so appending keeps order. GET becomes a binary search for the greatest timestamp at or below the query. That's the whole solution.
How hard is this OA question really?+
Medium at most. There's no tricky algorithm, just a hash map and a binary search. Most failures come from off-by-one bugs in the search, or from forgetting to return an empty string when the key is missing or the query is before the first timestamp.
Do I need to sort the timestamps myself?+
No. The problem guarantees SET timestamps are strictly increasing for each key, so each key's list is already sorted as you append. Only GET timestamps arrive in any order, and since you binary search each one independently, order doesn't matter.
What edge cases should I test before submitting?+
Test a GET on a missing key, a GET before a key's first timestamp, a GET exactly at a stored timestamp, and a GET far beyond the last one. Also check that multiple keys keep separate histories, and that output only includes GET results in order.
How do I prepare for this in 48 hours?+
Write the solution once from scratch. Parse timestamps to integers, keep a map of key to list, and code the upper-bound binary search without a library helper. Then trace both examples by hand. That covers it, and a similar design problem will feel familiar.