Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

for this kind of problems first identify the problem entities:
---- Problem State
1. in a restaurent there are different tables (say x in no) of different capacities .
2 .we can book a table of capacity n for m people (m<=n);
3. a table can be booked only if there is suitable time difference between two bookings
4. booking can be done only for particular no of hours for which restaurent opens .

--- what will be input from external interface

int CheckTableAvailability(int NumPeople, time_t TimeOfBooking, int *tableNumber, time_t *alternativeTime) 
{
if(isTable_Available(NumPeople,TimeOfBooking))
{
*tableNUmber=isTable_Available(NumPeople,TimeOfBooking);
return 1;
}
if(alternate_time(NumPeople,TimeOfBooking))
{
alternatetime=alternate_time(NumPeople,TimeOfBooking)
return 2;
}
else
{
cout<<"no Booking possible";
return 0;
}

}

- This function will tell whether the booking is possible or not. If possible on the input time it will
return 1 and file the tableNumber. If not on the input time, but at some time near to that, it will
return 2 with the alternativeTime and TableNumber that can be booked. If not at all possible then it will return 0.
bookTable(contactDetails, tableNumber, time_t TimeOfBooking)
Extra functionality
for CheckTableAvailability , it can also return an array of tableNumber possible for booking. Like some restaurants have different sections (smoking zone, pool side, garden side etc) which will give the customer a choice to make.

Class: Table
{
int TableId;
int SeatingCapacity;
string speciality;
}

Class Booking
{
int bookingId;
int TableId;
time_t startTime;
customerDetails;
}

Class: BookedTables
{
HashTable bookings ( key: timeslot, value: int booked[NumTables] );
// int array will contain whether the table is booked or not for this time slot. A value of 0 means not booked. A value other than 0 represents a booking id
}

- zeroByzero January 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think you'll also need the duration for which the booking needs to be done. It's similar to managing a calendar.

- LMV February 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 votes

I would add the following functionality to your class.
1. CancelReservation (cancel the existing reservation)
2. AddToWaitList ( If there is no availability, add to the wait list.)

- SR February 09, 2013 | Flag
Comment hidden because of low score. Click to expand.
3
of 3 vote

use queue+hashmap, queue is for keeping order and hashmap is for lookup.
need to realize AddReservation(), DeleteReservation() and SearchReservation()

- ds January 10, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

1. One superClass - Individuals (Name, Cell No., designation, etc)
2. Two subClasses - Employee and Guests should extend the Individual superclass and implement the corresponding methods.
3. Class - Table{} which will contain the guest object.
4. SuperClass - Menu {}
5. Class - Order should extend the superclass, Menu. and Order objects should be stored in a queue for processing.
6. A hashMap<Table No., Order index in the Queue> to track the status of object.
7. Class - Bill should also extend the super class Menu for processing the bills.
8. An additional queue to track the guests who have not been allocated the table as all tables might get busy some time. So when a table is freed, next guest from the queue is dequeued.
9. When a person is allocated a table, it should be assigned a waiter // we can use a queue to keep track of available waiters.....

- A January 27, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

I like most of answers here, one thing i would like to add is that
Wait queue is going to be specific to the type of table a particular party requested and not in terms of which party sent a request for reservation first..,

So, if a wait queue in sorted of request time has party of given size, 2,3,4,5,6,9,4,13,

If a table of capacity 15 just got freed, we will let the party of 13 get seated, although that depends on the restaurant policy, i am assuming that, idea is profit maximisation!!

- Tanmay Varun December 15, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

If its a system design question as for TPM the approach could be

#Questions to interviewer
--------------------------------------
Is the restaurant open all days? -Yes
Can we consider the open time is limited - Yes
Does it have multiple seating location - ex: open terrace, inside
Does it have corporate discounts or any other discounts? - Yes
Is it an upscale or a local restaurant where walk in is permitted? - Only via online booking
Do you want to book it only after some amount of payment? - yes
Is it online booking or call booking - online booking / a call booking will allow the staff to book the restaurant in your name
Can the user book couple of days in advance? -Yes
Coupons Allowed?
Does this Restaurant have other chains within the city - to redirect if a particular location is full? - no

Requirement and Approach explanation to interviewer
------------------------------------------------------------------------
Req Nugget:

* This is an upscale restaurant
* User can book by calling the restaurant/ Online
* User can book in advance for a week
* Allows corporate discounts
* Allows coupons
* If small babies are coming need to arrange for a Baby Seat
Approach Nugget:
*I will start by identifying user, customers, constrains, and the build the requirements and prioritize them.
*Further I will create a High level design (UML Usecase diagram followed by Class Diagram/Entity relationship diagram)
* Further I will check if there are any bottle necks?, any scalability factor and if there are any ways I can optimise by bringing in some pattern identification.
* Then I will check how I will measure my success (both Qualitative and Quantitative)

Identify user & customer (Add personas)
-------------------------------------------------------
Customer:
User who books the restaurant
John: Works in Amazon and is coming with his 13 co-workers to celebrate a successful release
Ravi & Family : has his wife and a newborn baby, he is coming to celeberate his wedding aniversary

User:
Restaurant Staffs (ex: Booking Staff, Waiter, Clearing Staff)
Martha: is the booking staff

Constraints
--------------------
Martha have a tough time especially when people do not turn up, and since her phone is always buzzing for new booking she keeps missing to call guests who does not turn up even after 15 min, there by wasting precious Tables which remain empty

Use cases
-------------------
"Customer:
Ability to login and book table/tables
* Book Seats: Name, Company (Optional), Expected time, Expected Date, Number of Seat required, Seat preference (Indoor, Outdoor), children below 2
Returns a booking ID
* Cancel Seats : with booking ID

* Assumption after discussing with interviewer : payment is done at the restaurant else we need to have a payment gateway also attached to booking system

For Martha's Problem of customer not turning up, we will provide a notification for her to call the customer to check if they are late or have forgot to cancel"

High level Design + UML Usecase diagram + Class Diagram
--------------------------------------------------------------------------------
Create Class diagram considering
A UML Use case diagram + ( UML Entity Relationship Diagram or UML Class Diagram) can be used
Customer Class
* Customer Name
* Customer ID

Booking Class
* Customer ID
* Date
* Time
* Table IDs allocated
* Number of persons

Table Class
* Table ID
* Total Seats
* Type of seat (indoor/ outdoor)

Payment Card Class
* Amount
* Card ID
* Expiry Date
* Payment Type

Order Class
* Food Item ID
* Food Item Qty

Food Class
* Food ID
* Food Item Cost
* Food Item category

Adding Intelligence
---------------------------
* If we have a system which can
* Keep track of time taken for a customer
* Type of customer (corporate/ Family)
* Date (weekend/weekdays)
* Time (Breakfast/ Lunch/ Dinner)
* Location of the seating
# we will come to know how much time it generally takes and adjust the average time to ensure
* we can provision more booking by optimising
* Avoid frustration from customer for them to wait

* If we keep track of the Menu most often selected by the customer/customers
# we can reduce the waiting time and have specific menu work to start in advance

- Abraham George July 31, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

UsmanMasood Not getting anything please help

- Anonymous July 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what abt SMS message for booking.

- Anonymous July 24, 2017 | 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