Question: ToDo - Roadmap Outlook Dashboa Student My Day coderbyte.com / editor / LRU Cache:Java / :candidate#usernqgxh 2 wnz coderbyte Time lefi: 0 hours, 2 6
ToDo
Roadmap
Outlook
Dashboa
Student
My Day
coderbyte.comeditorLRU Cache:Java:candidate#usernqgxhwnz
coderbyte
Time lefi: hours, mlnutes
medium
LRU Cache
Have the function LRUCache traxre take the array of characters stored in straxr, which will contain characters ranging from to in some arbitrary order, and determine what elements still remain in a virtual cache that can hold up to elements with an LRU cache algorithm implemented. For example: if straxr is CDAPEDZl then the following steps are taken:
A does not exist in the cache, so access it and store it in the cache.
B does not exist in the cache, so access it and store in in the cache as well. So far the cache contains: AB
Same goes for so the cache is now:
Same goes for so the cache is now: ACD
Now is accessed again, but it exists in the cache already so it is brought to the front:
E does not exist in the cache, so access it and store it in the cache:
does not exist in the cache so add in to the front and remove the least recently used element: D
Now the caching steps have been completed and your program should return the order of the cache with the elements joined into a string, separated by a hyphen. Therefore, for the example above your program should return CAEDZ
Examples
Input: new String
Output:
Output:
Browse Resourees
powered by Google
Search for any help or documentation you might need for this problem. For example: array indexing, Ruby hash tables, etc.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
