Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
LRU Cache
Bookmark
Input
Standard
All Hits
All Evictions
Custom
capacity
=
2
,
operations
=
[put(1,1), put(2,2), get(1), put(3,3), get(2), put(4,4), get(1), get(3), get(4)]
LRUCache(2)
put(1, 1)
put(2, 2)
get(1)
=
?
put(3, 3)
get(2)
=
?
put(4, 4)
get(1)
=
?
get(3)
=
?
get(4)
=
?
size 0 / 2
MRU
map
(empty)
hash map for O(1) lookup + doubly linked list for recency
algo
master
.
io
Step:
LRU Cache initialized with capacity 2: a hash map for O(1) lookup + a doubly linked list for recency order.
0 / 45
Input
Standard
All Hits
All Evictions
Custom
capacity
=
2
,
operations
=
[put(1,1), put(2,2), get(1), put(3,3), get(2), put(4,4), get(1), get(3), get(4)]
0 / 45
LRUCache(2)
put(1, 1)
put(2, 2)
get(1)
=
?
put(3, 3)
get(2)
=
?
put(4, 4)
get(1)
=
?
get(3)
=
?
get(4)
=
?
size 0 / 2
MRU
map
(empty)
hash map for O(1) lookup + doubly linked list for recency
algo
master
.
io
Step:
LRU Cache initialized with capacity 2: a hash map for O(1) lookup + a doubly linked list for recency order.