StartUp Interview Question for Developer Program Engineers


Country: United States
Interview Type: In-Person




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

Which company was this for?
The aim of a Hashmap would be to store key-val pairs and allow search, insert and del operations in constant O(1) time.
A simplest implementation of a hashmap would be using a Hash Function H which gives you the index i using the key ( i = H(key) ). Using the index we will store the key-val at the appropriate place. However, if the index location is not empty, the simplest solution is to link the new key-val entry to the old one using a Linked List. Ofcourse, there are other solutions as probing and double hashing.

- puneet.sohi December 03, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The simplest hash map is an array. Assuming that there is sufficient space, on a collision, you can increment in a predictable way to the next empy slot and put the value there. In all cases you need to put both key and value into the array.
As long as the method to increment is the same for insert and search, and you compare the key, you can take care of conflicts that way.

But you need to create a randomizer function that will give the same value for the same key.

- haroud December 04, 2015 | 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