Look Up the Config Value That Was Live at Any Timestamp

Last updated: November 29, 2026

Quick Overview

Design a store with set(key, value, timestamp) and get(key, timestamp) that returns the value whose set time is the largest one not exceeding the query time, or an empty string if none exists. Timestamps for a given key are set in increasing order.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Design a store with set(key, value, timestamp) and get(key, timestamp) that returns the value whose set time is the largest one not exceeding the query time, or an empty string if none exists. Timestamps for a given key are set in increasing order.

Meta ships ranking and feature configs continuously, and debugging a regression often means asking which config was live when a request was served. Interviewers use this to check that you exploit the sorted insert order with binary search rather than scanning history.

What the Interviewer Expects
  • Confirm that per-key timestamps are strictly increasing
  • Store per-key time and value lists in insertion order
  • Use bisect_right minus one to find the floor timestamp
  • Return the empty sentinel when the query predates the first set
  • Discuss how to relax the ordering assumption
Key Topics to Cover
Binary search
Hash map
Versioned data
Data structure design
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What if set calls for a key can arrive out of order?
  • How would you support deleting a key as of a timestamp (tombstones)?
  • How would you cap history to the last N versions per key?
  • How would you serve this from multiple replicas with clock skew?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • set(key, value, t) records a version; per-key t values arrive increasing.
  • get(key, t) returns the value of the latest version with time <= t, else "".
  • Many keys, many versions per key,...
High-Level Design

Map each key to two parallel lists: timestamps and values. Because inserts arrive in time order, appending keeps the timestamp list sorted for free. A get binary searches the timestamp list for the ...


Submit Your Answer
Markdown supported