Approach hintTry it first, then revealHide
Combine a hash map from key to list node with a doubly linked list ordered by recency. Every access moves the node to the front and eviction removes the tail, all in O(1).
Combine a hash map from key to list node with a doubly linked list ordered by recency. Every access moves the node to the front and eviction removes the tail, all in O(1).