Implement a priority-based cache with get, set and evictCache.
Unlock detailed company stats for this questionUpgrade
Implement a cache with get(key: string), set(key: string, value: string, priority: int) and evictCache. Eviction removes the key/value pair with the highest priority number. On a tie, remove the least recently accessed pair. Working code was not required and some functions could be stubbed while talking through the mechanics.
Expect follow-ups like
- Is there any opportunity to improve the time complexity of evictCache?
Format · Phone screen; working code not expected, stubbing out functions allowed.
Community answers
No answers contributed by the community yet.


