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.com/editor/LRU Cache:Java/:candidate#usernqgxh2wnz
coderbyte
Time lefi: 0 hours, 26 mlnutes
medium
LRU Cache
Have the function LRUCache (s traxre) take the array of characters stored in straxr, which will contain characters ranging from A to Z in some arbitrary order, and determine what elements still remain in a virtual cache that can hold up to 5 elements with an LRU cache algorithm implemented. For example: if straxr is [,"B","C","D",'AP,"E','D','Z'l, then the following steps are taken:
(1) A does not exist in the cache, so access it and store it in the cache.
(2) B does not exist in the cache, so access it and store in in the cache as well. So far the cache contains: [A.""B1].
(3) Same goes for C, so the cache is now: .
(4) Same goes for D, so the cache is now: [A',"B","C","D]).
(5) Now A is accessed again, but it exists in the cache already so it is brought to the front: [B',C,C',A].
(6) E does not exist in the cache, so access it and store it in the cache: [','C","D','A","E"'].
(8)Z does not exist in the cache so add in to the front and remove the least recently used element: [",A,"E","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 C-A-E-D-Z.
Examples
Input: new String[]{''A'',B,A,C,A,B}
Output: C-A-B
Output: E-D-Q-Z-C
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.
 ToDo - Roadmap Outlook Dashboa Student My Day coderbyte.com/editor/LRU Cache:Java/:candidate#usernqgxh2wnz coderbyte

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!