Amazon Interview Question for Software Engineer / Developers






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

TRIE is suitable for both a) and c)
a) search in dictiorry
c) typing prefix of a valid string suggests valid words

---------

Hash table is suitable for
b) given a string find all valid anagrams in a dictionary
---------

so we need TRIE + HASH data stractures to satisfy all operations

- siva.sai.2020 December 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

trie

- Anonymous December 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

suffix tree for a)
hash table for b)
prefix tree for c)

- Anonymous December 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

there can be only one structure of dictionary, as I understand

- Anonymous December 10, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

a) Suffix Tree
b) To find valid anagrams
first sign all the words (alphabetical sort)
sort the words
compare the adjacent.
another way is to use hashing

c) this is autocomplete feature. in this case, a ternary search tree is used

- sreekar.m December 10, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I guess only a prefix tree would do good.
A and C are directly possible by the trie

for B we can have permutation algorithm to look into the data structure for possible trie if there is a limitation to the space complexity to be O(n)

if not hash table with the values being the link list to the possible anagrams(nodes in trie)

- ketz January 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A multiway trie(256 way for ascii)Trie supports search and string with given prefix directly.
And search for anagrams can also be easily implemented efficiently.

Sketch for anagrams:
Say search for "abcd"

search(root,"abcd")
{
Node[] nodes = // get nodes for a,b,c,d as the characters.
search(nodeforchar(a), "bcd");
search(nodeforchar(b), "acd");
search(nodeforchar(c), "abd");
search(nodeforchar(d), "abc");
}

- Krishna January 15, 2011 | 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