Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

there is one log entry per user?

- Johann January 24, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can use Priority Queue (represented by Doubly linked List), having pointers to both head and tail. Also maintain a hashtable which maps to nodes based on URL.

Foreach entry
{
       if(URL is in hashtable)
       {
            Delete node from temp position, update count;
            insert into head 

       }
       else
       {
             Insert Node into head of DLL and set count to 1 
        }

}

GetTop3()
{
   Retrieve first 3 nodes from the DLL, since they were accessed most recently.
}

- juny January 25, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think you still misunderstood the question. It asks for top sequence of 3 urls, not top 3 urls.

- Guy January 25, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Plus, this will take O(nlogn), since for each url, you are deleting and inserting back to the priority queue.

- Guy January 26, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Create a hash map with the user Ids as a key(s), the value of a particular user would point to another hash map with indexes representing the sequence of {3} websites and a value that is the count of that sequence. After generating the data structure, simply iterate through the users and their sequence of {3} values and store the maximum sequence until you've gone through both hash maps.

- NA January 26, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can use a TRIE data structure, where every entry is a URL and we build the TRIE in the same order as in the log. At the leaf node we maintain the count of the sequence

- Learner February 01, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.


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