← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Uber SWE coding round, got a binary search problem dressed up as a key-value store design. Pretty standard once you see what they're actually asking for.

Questions Asked (1)

Q1

Design a time-based key-value store that supports storing multiple values per key at different timestamps, with a lookup that returns the value at the largest timestamp less than or equal to the queried time.

Algorithms & Data StructuresData Modeling
Author's notes

Took me a minute to stop thinking about this as a system design thing and realize it's just binary search on a sorted list of timestamps.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify requirements and constraints, then propose a design using a hash map where each key maps to a list of (timestamp, value) pairs sorted by timestamp. For set, append and keep sorted (or use binary search for insertion); for get, binary search for the largest timestamp ≤ query time. Discuss trade-offs and potential optimizations like using a balanced BST or time-series database for scalability.

Pro tip: Mention that timestamps are monotonically increasing in typical use cases, so appending to the list maintains sorted order without extra sorting. Also, discuss how to handle large-scale data with distributed storage and caching, showing awareness of Uber's scale.

1. Clarify Requirements

Ask about expected data volume, read/write ratio, timestamp granularity, and whether timestamps are unique per key. Confirm that get should return the value at the largest timestamp ≤ given time, and what to return if no such timestamp exists.

2. Choose Data Structures

Propose a hash map from key to a sorted list of (timestamp, value) pairs. For efficient lookup, use binary search on the list. Alternatively, consider a balanced BST (e.g., TreeMap) if insertions are frequent and out of order.

3. Design Operations

For set: if timestamps are increasing, append to the list; otherwise, insert in sorted order. For get: binary search for the largest timestamp ≤ query time and return the corresponding value, or empty if none.

4. Analyze Complexity

Discuss time and space complexity: set O(1) amortized if appending, O(log n) for binary search insertion; get O(log n) for binary search. Space O(n) for n entries.

5. Discuss Scalability and Trade-offs

Address how to handle large-scale data: sharding by key, using a distributed database like Cassandra or Redis with sorted sets, and caching hot keys. Mention trade-offs between in-memory and persistent storage.

Key Points to Mention

  • Hash map with sorted list per key for efficient timestamp-based lookup
  • Binary search to find the largest timestamp ≤ query time
  • Handling out-of-order timestamps: either assume monotonic or use insertion sort
  • Time complexity: O(log n) for get, O(1) amortized for set if appending
  • Scalability: sharding, distributed storage, and caching for large-scale systems
  • Edge cases: empty store, no matching timestamp, duplicate timestamps

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