ION Group | OA | Time to live Cache

Question · Posted Aug 2023

Implement a prototype of a time-to-live cache. Given a 2-d array of integers of size n x 2 data, data[i] represents that the ith data point was inserted into the cache at time data[i][0]. It lives in the cache for data[i][1] time. For an array of q queries, queries[q], find the number of data items in the cache at each time query[i]. Example 1 Suppose n = 3, q = 2 data = [105231, 183], [105334, 34], [105198, 543]] queries = [105338, 105410]. Data Index ...

The full answer & interview discussion are available to premium members.

Log in Create a free account