Back to problems

LRU Cache (with TTL and LFU Follow-ups)

Low-Level Design · ByteDance · Medium

LRU Cache Medium · Topics · Company Tags · Hints Design a fixed-capacity cache that evicts the least recently accessed key when it is full. The cache must support two operations: retrieving the value for a key and writing a key-value pair. Both operations must run in O(1) average time. Implement the LRUCache class: LRUCache(int capacity) initializes an empty cache with the given positive capacity. int get(int key) returns the value stored for key, or -1 if the key is not…

Checking your access…