Time-Based Key-Value Store

Medium · Binary Search · about 30 minutes

Asked at Anthropic, Block (Square), Coinbase, MongoDB, OpenAI, Oracle, Robinhood, Salesforce, Stripe, Citadel, ServiceNow, Workday, Intuit, Visa, Capital One, Plaid, Ramp, Perplexity, HubSpot, Elastic, Chime, SoFi, Affirm, Klarna, Revolut, American Express, xAI, Cohere, Hugging Face, Toast, Mistral AI, Dell Technologies, SAP, Rippling, Gusto, Brex, Mercury, Kraken.

Implement a store with set(key, value, timestamp) and get(key, timestamp), where get returns the value set at the largest timestamp ≤ the given timestamp, or "" if none. Timestamps for a key are set in increasing order.

Related guides