Amazon Interview Question for Software Engineer / Developers






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

I managed to do both Lookup and LRU Eviction in O(1) by creating a hybrid datastructure for the application. Combined a Hashtable and a LinkedList. The hashtable would be used for constant time lookup, when something is lookedup it is enqued to the front of the linked list. (the hastable had an object that stored the value and a reference to a LinkListNode).

And when I ran out of predifined room in the hastable, i kicked out the least recently used by dequeing the tail of the linked list, and kicking out the corresponding key/value pair from the hastable.

I also made the hashtable 2 times the capacity of the size of the LRU cap so that we would hopefully never have to grow the hastable as the critical load factor would never be aproached

- Muhariz Jabeer December 21, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

in java use linkhashmap.
it has a way of returning the least recently accessed element.

so iterate thru linkhashmap...if u dont find the element(page). get the least recently accessed element out and put the new page inside the collection.

- dharam September 22, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Where did u mention about queue ???
I came into picture only when you r deleting

- Rohit June 10, 2007 | Flag Reply


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