ZipRecruiter·Software Engineer·Technical Phone Screen
- You have an in-memory key-value store where each key maps to a collection of field-value pairs. Implement a scan(key) operation that returns all field-value pairs for a given key, sorted lexicographically by field name. Return an empty result if the key doesn't exist.
- Extend the store with a scan_by_prefix(key, prefix) operation that returns only the field-value pairs whose field name starts with a given prefix, again in lexicographic order.
- Walk through the time complexity tradeoffs between using a sorted map versus a linear scan with sort-on-read for both scan and scan_by_prefix. When does each approach make sense?
“Felt straightforward at first.”