AlgoScope

LRU Cache

Data structureintermediateCaches and Filters

Evicts the least recently used entry; a hash map plus a recency list gives O(1) get and put.

Decision · step 2 of 8LRU Cache: A hit moves the node to the front
1:10✓head

put 1 10: a new key with room to spare. It becomes the head, the most recently used.

Open in the player →or start at step 2

What you will see

An access moves the node to the front; eviction removes the back node.

How lru cache works →

Cost

getO(1)
putO(1)
SpaceO(capacity)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.

Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.

Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.

Related

Leads to

Topics that need this one first.

Taught by the same lesson

LRU Cache covers these too, in the same run.