PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Navan

Design time-based key-value store

Last updated: Mar 29, 2026

Quick Overview

This question evaluates competency in designing time-indexed in-memory key-value stores, including handling ordered timestamps and achieving efficient lookups through suitable data structures and algorithms.

  • medium
  • Navan
  • Coding & Algorithms
  • Software Engineer

Design time-based key-value store

Company: Navan

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Design an in-memory key-value store that supports time-based lookups. ## Operations Implement a class (or module) with the following methods: 1. `set(key, value, timestamp)` - Stores the string `value` for string `key` at integer `timestamp`. - Multiple values may be stored for the same key at different timestamps. 2. `get(key, timestamp)` - Returns the value associated with `key` for the **largest stored timestamp `t` such that `t <= timestamp`**. - If there is no such timestamp for the key, return an empty string (or `null`, but be consistent). ## Notes / Constraints - Timestamps for `set()` calls on the same key are non-decreasing. - Aim for efficient `get()` queries. - You may assume ASCII strings for keys/values. ## Example - `set("room", "A", 10)` - `set("room", "B", 20)` - `get("room", 5) -> ""` - `get("room", 10) -> "A"` - `get("room", 15) -> "A"` - `get("room", 20) -> "B"` - `get("room", 25) -> "B"`

Quick Answer: This question evaluates competency in designing time-indexed in-memory key-value stores, including handling ordered timestamps and achieving efficient lookups through suitable data structures and algorithms.

Navan logo
Navan
Nov 7, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
5
0

Design an in-memory key-value store that supports time-based lookups.

Operations

Implement a class (or module) with the following methods:

  1. set(key, value, timestamp)
    • Stores the string value for string key at integer timestamp .
    • Multiple values may be stored for the same key at different timestamps.
  2. get(key, timestamp)
    • Returns the value associated with key for the largest stored timestamp t such that t <= timestamp .
    • If there is no such timestamp for the key, return an empty string (or null , but be consistent).

Notes / Constraints

  • Timestamps for set() calls on the same key are non-decreasing.
  • Aim for efficient get() queries.
  • You may assume ASCII strings for keys/values.

Example

  • set("room", "A", 10)
  • set("room", "B", 20)
  • get("room", 5) -> ""
  • get("room", 10) -> "A"
  • get("room", 15) -> "A"
  • get("room", 20) -> "B"
  • get("room", 25) -> "B"

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

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

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