Instacart Interview Question

Problem broken into three phases 1. create a hash like data structure class that handles get and set. 2. Allow key to hold many values with each value having a timestamp. if get receives just they key, return latest value. If get receives both key and time, return the appropriate value. 3. modify get to return closest value with timestamp lesser than argument timestamp.

Interview Answer

Anonymous

May 8, 2019

1. create class with instance variable hash and methods get and set. 2. key is the key, value is an array of tuples [timestamp, value] 2a. use bsearch to reduce lookup of timestamp 3. modify bsearch to look for closest timestamp lesser than argument time

1