Ziprecruiter·Software Engineer·Technical Phone Screen
- Design an in-memory key-value store where each key maps to a set of field-value pairs. Support operations like set, get, scan (returns all pairs sorted lexicographically by field), and scan by prefix.
- Extend the key-value store to support TTL (time-to-live). Each operation now takes an explicit timestamp, and fields should expire a given number of time units after they're set. How do reads and writes behave when a field is expired or re-set?
- Compare lazy expiration (skip expired fields on read) versus active background expiration. What are the trade-offs in terms of memory usage and latency?
“The base version wasn't too bad.”