LRU Browser History

Implement a LRU cache to keep track of user browsing history. For example a user is browsing your website. The user clicks the pages in the following sequence: page1, page3, page1, page2
According to LRU algorithm, the cache state is [page3, page1, page2]. 
The user clicks page1, LRU cache state is [page1].
The user clicks page3, LRU cache state is [page1, page3]. We put page3 on top of page1. 
The user clicks page1 again, we move the page1 to the top. Now the LRU state is [page3, page1]
Finally the user clicks a new page2, the LRU cache state now is [page3, page1, page2]. 
Now give a list of strings representing the page links the user has visited, rethrn the the cache state as a list of page links. 
["a", "b", "c", "a"]
["b", "c", "a"]

Get one-to-one training from Google Facebook engineers

Top-notch Professionals

Learn from Facebook and Google senior engineers interviewed 100+ candidates.
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.

Customized Private Class

Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.