Amazon Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
I think you'll also need the duration for which the booking needs to be done. It's similar to managing a calendar.
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.....
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!!
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
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
- 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.
- zeroByzero January 11, 2013