PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Apple

Design a snapshotable key-value store

Last updated: May 18, 2026

Quick Overview

This question evaluates understanding of versioned key-value data structures, snapshot semantics, API design, complexity analysis, and reasoning about concurrency and durability trade-offs.

  • Medium
  • Apple
  • Coding & Algorithms
  • Software Engineer

Design a snapshotable key-value store

Company: Apple

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Design and implement a snapshotable key–value map supporting the following APIs: - S(key, value): set the current value of a string key to a string value. - G(key): get the current value for key (or null if absent). - Snapshot(): capture the current state and return a snapshotId (opaque string). - GS(snapshotId, key): get the value of key as of the given snapshot. Requirements: - Support arbitrarily many snapshots; later writes must not affect earlier snapshots. - Be space‑efficient across snapshots (avoid full copies; consider copy‑on‑write or per‑key versioned logs). - Target time complexity around O(log u) per operation where u is updates per key (justify alternatives). - Define behavior for overwrites, deletions, unknown keys, and consecutive snapshots without intervening writes. - Specify snapshotId generation and ordering guarantees. - Discuss how to extend to concurrency (reads during writes) and persistence/durability (optional). Example scenario to satisfy: S("a", "a-foo"); S("b", "b-foo"); id = Snapshot(); S("a", "a-foo-prime"); G("a") -> "a-foo-prime" GS(id, "a") -> "a-foo" G("b") -> "b-foo" GS(id, "b") -> "b-foo".

Quick Answer: This question evaluates understanding of versioned key-value data structures, snapshot semantics, API design, complexity analysis, and reasoning about concurrency and durability trade-offs.

Related Interview Questions

  • Find Common Prefix Across Strings - Apple (easy)
  • Find Minimum Processing Rate - Apple
  • Compute Earliest Bus Arrival - Apple (medium)
  • Find the Extra Edge - Apple (hard)
  • Rotate a Matrix In Place - Apple (medium)
Apple logo
Apple
Aug 8, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
8
0

Design and implement a snapshotable key–value map supporting the following APIs:

  • S(key, value): set the current value of a string key to a string value.
  • G(key): get the current value for key (or null if absent).
  • Snapshot(): capture the current state and return a snapshotId (opaque string).
  • GS(snapshotId, key): get the value of key as of the given snapshot. Requirements:
  • Support arbitrarily many snapshots; later writes must not affect earlier snapshots.
  • Be space‑efficient across snapshots (avoid full copies; consider copy‑on‑write or per‑key versioned logs).
  • Target time complexity around O(log u) per operation where u is updates per key (justify alternatives).
  • Define behavior for overwrites, deletions, unknown keys, and consecutive snapshots without intervening writes.
  • Specify snapshotId generation and ordering guarantees.
  • Discuss how to extend to concurrency (reads during writes) and persistence/durability (optional). Example scenario to satisfy: S("a", "a-foo"); S("b", "b-foo"); id = Snapshot(); S("a", "a-foo-prime"); G("a") -> "a-foo-prime" GS(id, "a") -> "a-foo" G("b") -> "b-foo" GS(id, "b") -> "b-foo".

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Apple•More Software Engineer•Apple Software Engineer•Apple Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL 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.