Interview Solution

One principle problem of educating software engineers is that they will not use a new method until they believe it works and, more importantly, that they will not believe the method will work until they see it for themselves. Humphrey

Least Recently Used (LRU) cache

Language Java | Level Intermediate | Category Interview Problems | July 24, 2015 4:52 pm

Comments


Interview Problem

Least Recently Used (LRU) cache algorithm removes the least recently used items first.
This algorithm keeps track of all items insertion order to delete the least recently used items first. If any item inserts or delete, the cache items lifetime change and update the cache.
Example:-
LRU size 4.
Insert 0,1,2,3.
Insert two number 4 and 5.
The LRU data updated with 2,3,4,5


Output

   					 
size:4 Items:0 1 2 3 
size:4 Items:2 3 4 5

				    

Comments



Please login to add comments.