Implement an in-memory storage with TTL and scans
Company: Ziprecruiter
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Take-home Project
Quick Answer: This question evaluates implementation of an in-memory two-level key->field->value store with TTL semantics, lexicographic scans and prefix filtering, and time-travel reads, covering competencies in data structures, time-based expiry handling, and maintaining correct state across monotonic timestamps.
Examples
Input: ([['SET', '1', 'k', 'a', '1'], ['GET', '2', 'k', 'a'], ['COMPARE_AND_SET', '3', 'k', 'a', '1', '2'], ['GET', '4', 'k', 'a']],)
Expected Output: ['1', 'true', '2']
Explanation: Set/get/CAS.
Input: ([['SET_WITH_TTL', '1', 'k', 'a', 'v', '3'], ['GET', '3', 'k', 'a'], ['GET', '4', 'k', 'a'], ['GET_AT', '5', 'k', 'a', '2']],)
Expected Output: ['v', '', 'v']
Explanation: TTL and history.
Input: ([['SET', '1', 'k', 'b', '2'], ['SET', '2', 'k', 'a', '1'], ['SCAN', '3', 'k'], ['SCAN_BY_PREFIX', '3', 'k', 'a'], ['COMPARE_AND_DELETE', '4', 'k', 'a', '1'], ['SCAN', '5', 'k']],)
Expected Output: ['a(1),b(2)', 'a(1)', 'true', 'b(2)']
Explanation: Scans and delete.