Versioned Key Value Store for Profile Field History

Last updated: November 29, 2026

Quick Overview

Implement a store with set(key, value, timestamp) and get(key, timestamp), where get returns the value set for key at the largest timestamp less than or equal to the given one, or an empty string if none exists.

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

0

0

0 solved


Implement a store with set(key, value, timestamp) and get(key, timestamp), where get returns the value set for key at the largest timestamp less than or equal to the given one, or an empty string if none exists.

LinkedIn keeps profile history for features like 'show what changed' and for compliance. The question checks per-key ordered storage, binary search for the floor timestamp, and handling out-of-order writes.

What the Interviewer Expects
  • Stores a sorted list of timestamps and values per key
  • Uses bisect_right minus one to find the floor
  • Handles get before any set and timestamps before the first write
  • Discusses out-of-order inserts with insort versus append
  • Mentions memory and retention policies
Key Topics to Cover
binary search
design a data structure
versioning
hash map
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
  • How would you support deleting a key as of a timestamp (tombstones)?
  • How would you persist this efficiently on disk?
  • What if you also need range queries for all changes in [t1, t2]?
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 is called with timestamps that are usually increasing per key but may arrive out of order from retries. get(key, t) returns the latest value at or before t. Same timestamp set twice keeps the ...

High-Level Design

Map each key to two parallel lists: times and values. On set, if t is at least the last timestamp, append (or overwrite when equal), which is O(1) for the common case. Otherwise insert at the bise...


Submit Your Answer
Markdown supported