PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Lyft

Implement command-driven in-memory key-value database

Last updated: Apr 8, 2026

Quick Overview

This question evaluates a candidate's ability to design efficient in-memory data structures and implement transactional semantics for operations like SET/GET/DELETE/COUNT, including handling nested transactions, rollbacks, and commits.

  • Medium
  • Lyft
  • Coding & Algorithms
  • Software Engineer

Implement command-driven in-memory key-value database

Company: Lyft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Implement a command-driven in-memory key–value database. Supported commands (one per line): 1) SET key value 2) GET key → print value or NULL 3) DELETE key 4) COUNT value → print how many keys currently map to this value 5) BEGIN → start a transaction 6) ROLLBACK → undo changes in the most recent open transaction; if none, print NO TRANSACTION 7) COMMIT → make all open transaction changes permanent. Constraints: up to 100,000 commands; keys and values are ASCII strings; average O( 1) per operation; memory must remain within reasonable bounds. Design data structures to support COUNT efficiently and implement transactional semantics using an undo log or equivalent. Specify I/O format precisely and discuss edge cases (nested transactions, deleting non-existent keys, multiple keys sharing a value).

Quick Answer: This question evaluates a candidate's ability to design efficient in-memory data structures and implement transactional semantics for operations like SET/GET/DELETE/COUNT, including handling nested transactions, rollbacks, and commits.

Related Interview Questions

  • Implement Grid Spread and Transactional Store - Lyft (hard)
  • Assign Minimum Workers to Jobs - Lyft (medium)
  • Solve substring and worker assignment - Lyft (medium)
  • Implement Cache and Key-Value Store - Lyft (medium)
  • Implement pagination and a time-versioned key-value store - Lyft (Medium)
Lyft logo
Lyft
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
15
0

Implement a command-driven in-memory key–value database. Supported commands (one per line):

  1. SET key value
  2. GET key → print value or NULL
  3. DELETE key
  4. COUNT value → print how many keys currently map to this value
  5. BEGIN → start a transaction
  6. ROLLBACK → undo changes in the most recent open transaction; if none, print NO TRANSACTION
  7. COMMIT → make all open transaction changes permanent. Constraints: up to 100,000 commands; keys and values are ASCII strings; average O(
  8. per operation; memory must remain within reasonable bounds. Design data structures to support COUNT efficiently and implement transactional semantics using an undo log or equivalent. Specify I/O format precisely and discuss edge cases (nested transactions, deleting non-existent keys, multiple keys sharing a value).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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

Master your tech interviews with 7,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.