LRU Cache
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
put 1 10: a new key with room to spare. It becomes the head, the most recently used.
What you will see
An access moves the node to the front; eviction removes the back node.
Cost
| get | O(1) |
|---|---|
| put | O(1) |
| Space | O(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.