Company: Cisco_28thjuly
Difficulty: medium
A monitoring service keeps an in-memory time-versioned key-value store . Every key is versioned independently, and every version is stamped with an integer timestamp. The store supports exactly two operations, which arrive one after another as a stream: set(key, value, timestamp) — record that key held value at time timestamp . get(key, timestamp) — return the value recorded for key whose stored timestamp is the greatest timestamp that is less than or equal to the queried timestamp . This is a predecessor lookup, not an exact match. If key has no recorded version with a timestamp at most the queried one at the moment the query is executed , return the not-found sentinel -1 . Two properties of the stream matter: The stream is processed strictly in the order given. A get may only see versions written by set operations that appear earlier in the stream ; a version written later is invisible to it, even if its timestamp is smaller. The timestamps supplied to set are not assumed to arrive i