PracHub
QuestionsLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of time-versioned data storage, related data-structure selection, handling of overwrite semantics at equal timestamps, and the ability to reason about correctness and complexity trade-offs.

  • hard
  • Netflix
  • Coding & Algorithms
  • Software Engineer

Implement a Versioned Key-Value Store

Company: Netflix

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Onsite

Design and implement an in-memory versioned key-value store. Requirements: - `put(key, value, timestamp)`: store `value` for `key` at the given integer `timestamp`. - `get(key, timestamp)`: return the value for `key` with the greatest write timestamp less than or equal to `timestamp`. - If no such version exists, return `null`. - A key may be updated many times. - If the same key is written multiple times at the same timestamp, the latest write should overwrite the previous value at that timestamp. - Discuss the time and space complexity of your implementation. Example: ```text put("campaignA", "v1", 10) put("campaignA", "v2", 20) get("campaignA", 15) -> "v1" get("campaignA", 20) -> "v2" get("campaignA", 5) -> null ```

Quick Answer: This question evaluates understanding of time-versioned data storage, related data-structure selection, handling of overwrite semantics at equal timestamps, and the ability to reason about correctness and complexity trade-offs.

Design and implement an in-memory versioned key-value store. Process a sequence of operations of two types: - put(key, value, timestamp): store value for key at the given integer timestamp. - get(key, timestamp): return the value for key with the greatest write timestamp less than or equal to timestamp. If no such version exists, return None (this represents null in Python). A key may be updated many times. If the same key is written multiple times at the same timestamp, the latest write overwrites the previous value at that timestamp. For this coding problem, implement a function that receives all operations in batch form and returns the results of every get operation in order.

Constraints

  • 0 <= n <= 20000, where n is the number of operations
  • len(actions) == len(keys) == len(values) == len(timestamps)
  • actions[i] is either "put" or "get"
  • timestamps[i] are integers in the range [-10^9, 10^9]
  • Keys and stored values are strings

Examples

Input: (['put', 'put', 'get', 'get', 'get'], ['campaignA', 'campaignA', 'campaignA', 'campaignA', 'campaignA'], ['v1', 'v2', '', '', ''], [10, 20, 15, 20, 5])

Expected Output: ['v1', 'v2', None]

Explanation: campaignA has versions at timestamps 10 and 20. Query 15 returns v1, query 20 returns v2, and query 5 has no earlier version.

Input: (['put', 'put', 'get', 'get'], ['k', 'k', 'k', 'k'], ['a', 'b', '', ''], [5, 5, 5, 6])

Expected Output: ['b', 'b']

Explanation: The second put overwrites the value for key k at the same timestamp 5. Both gets return the latest value b for timestamp 5.

Hints

  1. Store the version history for each key separately using a hash map.
  2. If each key keeps its timestamps sorted, you can use binary search to find the latest timestamp less than or equal to a query time.
Last updated: May 23, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Simulate a TTL Cache with LRU Eviction - Netflix (medium)
  • Compute Minimum Task Completion Time - Netflix (medium)
  • Solve String Arrays and Row Deduplication - Netflix (medium)
  • Implement Cache, Undo, and DFS - Netflix (medium)
  • Implement Streaming Word Counter - Netflix (medium)