Google Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
2
of 2 vote

The question looks a little incomplete in terms of the problem statement. Hashmap and linkedlist seems to me LRU cache implementation. The items (keys) of the hashmap point to the nodes in linked list and the payload of linked list has the value (page content cache). After every fetch operation the head points to the element just fetched. That way the last element is always the least recently used and would be thrown off the cache when the cache is full with n keys. This way the caching server would work optimally by having a high cache hit for frequently used pages and a cache miss would occur more frequently for infrequently visited pages.

- NEO May 06, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Caches are present in server side as well.
For example a DB cache that chaches frequent SQL query results. This will prevent frequently run queries from hitting the DB server very often. Example, if you have a dropbox for the list of states and if the list is maintained in DB you dont have to always fetch from the DB. THe webserver will fetch that only once and then caches at the server side.

- Gokul March 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

Lot of clients and only one server implies that the data in the cache will be flushed out soon as you cannot store data of all the urls data in cache. So, cache will not help in reducing the response time

- Vishal March 08, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Im thinking hashmap had so many hash collisions... collisions are implemented in linkedlist format

- swathi1243 March 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This question submitter, a user named 'Guy', has been submitted over 50 "Google" questions. He/She has been spamming with incomplete and ambiguous questions and yet all the other users are trying to answer these fake questions. What a waste of time!

I reported this user so many times and yet the questions are keep coming!

- Anonymous June 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

LinkedList and hashmap. Use LinkedList for the LRU data structure. Use hashmap to locate the LinkedList element in O(1) time.

- allen.lipeng47 January 04, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
1
of 1 vote

I think it means the cache is a LRU (Least Recently Used). It's implemented as linked list + hash map (eg. LinkedHashMap in Java). When the cache is presented with an URL, it first checks if the URL is present in the hash map. If so, it returns the corresponding content, and also moves the corresponding element in the linked list to the front to indicate that this URL has just been fetched. Otherwise, it removes the last element from the linked list and also from the hash map, and inserts this new URL to the front of the linked list and to the hash map.

- Sunny March 07, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

So this means, when there is only one server, there will be limited cache and the process of removing the last element from the linked list and hash, and inserting new URL to the front will be frequent. In this situation, if the link list has keys in order of most frequently requested URLs instead of most recently requested should work better

- Anonymous March 07, 2014 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More