Quant Memo
Coding/●●●●●

First quote at or after a timestamp

A feed records (timestamp, value) pairs per key with strictly increasing timestamps. Support:

  • record(key, value, timestamp).
  • get_after(key, timestamp), return the value of the earliest record whose time is >= timestamp, or None if none exists.
times for "px": [1, 4, 7], values: [10, 40, 70]
get_after("px", 2)  -> 40     # earliest time >= 2 is t=4
get_after("px", 4)  -> 40
get_after("px", 8)  -> None   # nothing at or after t=8

Make get_after run in O(logm)O(\log m).

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions