Amazon Interview Question for Software Engineer / Developers


Country: India




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

Have 3 hash tables named PhoneMap, NameMap and AddressMap linked to each other.
unordered_map<string,string> AddreddMap;
unordered_map<string, AddreddMap::iterator> NameMap;
unordered_map<string, NameMap::iterator> PhoneMap;

With any input, we can look up the remaining two in O(1).

- PRB September 13, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It is not mentioned that any of the fields aren't same.. there may be cases where people have same name but different phone numbers and address.

- Anonymous September 21, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 vote

Use hash table where the hash function returns a number in which few bits come from name, few from phone and few from address,
For e.g. suppose hash function for name return a number in range [0,39] say 14,
hash function for phone number returns a number in range [0,9] say 3,
hash function for address returns a number in range [0,9] say 5.
So the entry will hash in bucket 1435.

To search a phone number, given the value returned by the hash function for phone
number say 7, then search all buckets of form xx7x.

For generating the bucket numbers, use a for loop in this manner

for(i=0;i<40;i++)
{
for(j=0;j<10;j++)
{
int sum = i*100 + z*10 + j; //Here z=7 and z is already supplied
}
}

- Neeraj September 13, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how about using suffix tree. if we are using hash in order to search anything we need to enter correct and complete value. example if i'm searching for number "9912345678" then i need to enter correct value then only i'll be able to fetch all the data.

Assumption: we are designing this data structure for smartphones.

- Anonymous September 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It can be done in many ways. Some of the ways are:
(1) Use hashing with chaining.
(2) Or use tries.

- Anonymous September 21, 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