Back to problems

LRU Cache with Expiration

Object-Oriented Programming · Oracle · Medium

Requirements Build an LRU cache that provides get(key) and put(key, value) operations in average O(1) time. Use the usual combination of a hash map from keys to nodes and a doubly linked list whose order represents recency of use. Follow-up: add an expiration duration for each stored entry. Once an entry's TTL has elapsed, get must report it as missing, regardless of whether capacity-based eviction has removed it. API For the TTL extension, adapt the insertion operation so…

Checking your access…