Amazon Interview Question for SDE1s


Country: United States




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

Assuming there can be more than 1 three set sequences:

have a hash table with key as a string (based on sequence of pages, say strcat of the 3) and value as count(integer value).

have a struct having 2 elements-integer value for max count and vector of strings for the 3 page sequence.

if key exists in hashmap increase count, else add to map with value as 1

if (hashmap_count>struct_count)
{
//first call vector.erase
//update struct_count value
// then push back the new sequence string
}
else if (hashmap_count==struct_count)
//push back this string also to the vector. no need to worry about duplicate as it will never happen

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

Hash Table

- Albert Pinto January 06, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

What should be the key and what should be the value ?

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

We can use a trie data structure storing the count of the sequence followed to reach the node.
The element nodes store a pointer to a linked list. Whenever we get a sequence we move through the trie and increment the count at the specific node in the linked list using the pointer.
We can traverse the linked list in O(n) to find the most repeated sequence.

- Anonymous January 07, 2014 | 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