design Elevator
Design interview questions can be pretty vague and answers often depends on interviewers requirement.
But there are some generic steps that you can follow:
Gather requirements
Think about best data structure that can be used
How important are Latency, Consistency and Availability for your system?
How is concurrency handled in your system?
How many classes will be there and what will be their methods
For example,
Some simple requirements for your question would be:
For users:
call an elevator by pressing buttons in lobby.
Choose a floor
For System:
get all available elevators
choose any available elevator and send it on the requested floor (this can be optimized)
get list of all floors where elevator is supposed to make a stop
Classes :
1 | class ElevatorSystem { |
reference:
https://goo.gl/q1OYej