← Navan Interview Insights

Navan·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026Remote

Summary

Navan coding screen, got a time-based key-value store problem. Pretty classic but the binary search part tripped me up more than I expected.

Questions Asked (1)

Q1

Design a time-based key-value store that supports a set operation storing a key-value pair with a timestamp, and a get operation returning the value for the largest stored timestamp that does not exceed a given query timestamp.

Algorithms & Data StructuresSystem Design
Author's notes

I knew roughly where this was going once they said 'timestamp' but I fumbled the get logic for a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements and constraints, then propose a design using a hash map from keys to sorted lists of (timestamp, value) pairs. For set, append to the list; for get, binary search for the largest timestamp ≤ query timestamp. Discuss time/space complexity and potential optimizations like using TreeMap or balanced BST.

Pro tip: Mention that timestamps for set operations are strictly increasing, which allows appending without sorting and enables efficient binary search. Also, consider thread-safety and persistence if the system needs to scale.

1. Clarify Requirements

Ask about constraints: timestamp range, number of operations, concurrency, persistence, and whether timestamps are unique per key. Confirm that get should return the value with the largest timestamp ≤ query timestamp.

2. Choose Data Structures

Propose a hash map where each key maps to a list of (timestamp, value) pairs. Since timestamps for set are increasing, the list remains sorted. Alternatively, use a TreeMap for each key to allow floorKey operations.

3. Implement Operations

For set: append the new (timestamp, value) to the list for the key. For get: binary search the list for the largest timestamp ≤ query timestamp; if found, return the value, else return empty string or null.

4. Analyze Complexity

Set is O(1) amortized (append). Get is O(log n) where n is the number of timestamps for that key. Space is O(total number of set operations).

5. Discuss Optimizations and Edge Cases

Consider using a balanced BST or TreeMap for O(log n) get and O(log n) set if timestamps are not strictly increasing. Handle edge cases: empty store, key not found, query timestamp before all timestamps, and duplicate timestamps (if allowed, decide on overwrite or keep latest).

Key Points to Mention

  • Hash map with sorted lists per key for efficient lookup
  • Binary search to find the largest timestamp ≤ query timestamp
  • Time complexity: O(1) for set (amortized) and O(log n) for get
  • Space complexity: O(total number of set operations)
  • Handling edge cases: missing key, no timestamp ≤ query, duplicate timestamps
  • Potential use of TreeMap or balanced BST for alternative implementation

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.