Amazon Interview Question for Software Engineer / Developers


Country: Luxembourg
Interview Type: Written Test




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

Store the Name-Number pair in a Hash, with the number as key.
HashTable must be implemented in a separate chaining strategy, storing all the matching names in a list, against the key (phone number)

- Vasanthakumarsharma April 05, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Store the Name-Number pair in a Hash, with the number as key.
HashTable must be implemented in a separate chaining strategy, storing all the matching names in a list, against the key (phone number)

- Vasanthakumarsharma April 05, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Store the Name-Number pair in a Hash, with the number as key.
HashTable must be implemented in a separate chaining strategy, storing all the matching names in a list, against the key (phone number)

- Vasanthakumarsharma April 05, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is a database forbidden? That's the "right" approach. If you couldn't use a database server, then SQLite (ha ha ha). Ok, pure data structures then:

You'd need a series of data structures.

1.) hash table/map of primary-key to data (name, phone number, address perhaps).
2.) Associative containers for each one of the attributes that youd want to search on.
2.1) Suffix array to support searching. Value would be lists of associated keys of data. (Joh would link to all Johns, Johnathan, Johnny, etc)
2.2) You could stick the phone numbers, and addresses, and all data in here as well, to support the searching functionality.

- rotinom April 06, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

HashSet with equals method overridden to compare numbers if sufficient.

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

hasmap of type <str (for name), hashset<int> (for phone numbers)>?

- gaurav November 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

in Java : Hashmap<String,ArrayList<String>> would give something like this:

["John Smith": '555-5500', '555-5501', '555-5502']

I stored the phone numbers as strings, but you should ask the interviewer if you should consider a phone number as an Integer or String. Always ask to clarify the requirements before diving into code :)

- Anonymous April 03, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

?? how will you search through phone number.

- niraj.nijju April 03, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

?? what will you show when we will search for "joh"

- niraj.nijju April 03, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hmmm you are correct sir, I just thought about storing it, not searching it. I think the method suggested by @thelineofcode is better, so upvote his response :)

- Anonymous April 03, 2014 | Flag
Comment hidden because of low score. Click to expand.
-2
of 4 vote

You can construct Trie. Each node which represent the last letter for the name may have List<String> which stores numbers for given name.
Additional benefits for this solution are:
1) Sorting of phone book is very easy by only pre-order traversal of the trie
2) Finding names which matches given prefix

- thelineofcode April 03, 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