LFU Cache
Evicts the least frequently used entry, breaking ties by recency.
Decision · step 3 of 10LRU Cache: LFU: the oldest entry survives because it is the most used
get 1: a hit, value 10. Its count goes from 1 to 2, which moves it up past every entry with a lower count and to the front of the entries that share its new count.
What you will see
Frequency buckets; an access moves the node up one bucket.
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.