Amazon Interview Question for Software Engineer / Developers

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

A hash table would be needed only to ensure that unpark() is executed in constant time.
Once a Car is parked we need a mapping between the Car (identified by reg number) and the slop. And it must be added to the hash table.
For Park() just maintaining a free list would do. Once we execute Unpark() that slot must be added to the free list.

- jack March 30, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

u can find the class structure here:
google for: amazon-interview-question-design-an-oo-parking-lot/764955#764955

But for park() unpark() I think we would a hashtable ,
So a ParkingLot class would have a method say
{public assignSlotToCar(Car car); }
-> which would take in the car as the argument
and compute a hash-function to deliver a bucket(parking slot) for the car,only condition would be that the slot should be the same as the car, e.g. for a compact car, mid-size car, etc
Not sure about unpark() - should it just be a remove element form the hashtable ?

- V March 28, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

for the park() to be performed in constant time we can use a max-heap of the available parking spaces based on the value of a rank (computed separately e.g distance from the gate)
when a request for park comes we just remove the root element.

when parking space gets free it is added to the tree

for unpark to be performed in constant time we would need a hash table with carNo as the key and parkingspace object as the value.
to free we just remove the value from hash table and add the the available parking space tree

- ketz January 04, 2011 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


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


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