Coding Challenge

Time Based Key-Value Store

Medium
designbinary-search

Store values by timestamp and query the latest valid one.

Implement set(key, value, timestamp) and get(key, timestamp), where get returns the most recent value stored at or before the given timestamp.

Examples

Input: set("foo","bar",1), get("foo",1), get("foo",3)

Output: "bar", "bar"

Constraints

  • Timestamps for a key are strictly increasing

Preparing your coding workspace...