System design · must-tier · asked at Amazon, Apple, Google, Meta, Microsoft, Netflix

Elevator System

hardlldoodscheduling

Prompt

"Design the software for the elevators in an office building. Several cars, a few dozen floors, buttons in the hall and inside the cars. Show me the objects and how you decide which car answers a call."

Clarifying questions

  • How many cars and floors? Say 4 cars and 30 floors. Small enough that any scheduler is fast; large enough that a bad scheduler is visibly bad.
  • What inputs exist? Hall calls (floor + direction) and car calls (a floor pressed inside a specific car). Door open/close and emergency stop are follow-ups.
  • Is this real-time control or a simulation? A discrete simulation: the system advances in ticks, each tick a car moves one floor or spends one tick with doors open. The interviewer wants to see the state machine advance, not talk to hardware.
  • What is the goal of the scheduler? Minimize average wait time, avoid starvation. No express or zoned cars in the first version.
  • Can calls arrive while the system is stepping? Yes. Buttons are pressed from other threads (or callbacks) while the tick loop runs, so the request intake must be thread-safe.
  • Capacity limits? Ignore weight. Mention that a full car should skip hall calls.

Requirements

Functional

  • Accept hall calls and car calls at any time.
  • Assign each hall call to exactly one car; a car serves its stops in a sensible order.
  • Advance the whole system by one tick: move cars, open and close doors, clear served stops.
  • Expose car state (floor, direction, door) for a display.

Non-functional

  • No lost calls and no call served twice.
  • No starvation: a call placed at any floor is eventually served even under continuous load.
  • Scheduling cost per call must be small: O(cars) or O(cars x floors) is fine at this size.
  • Scheduler policy must be replaceable, because "compare two policies" is the standard follow-up.

Numbers

  • 4 cars x 30 floors = at most 120 distinct pending stops. One tick per second of simulated time. Even a naive O(cars x floors) evaluation per call is a few hundred operations, which frees you to choose the clearest algorithm rather than the cleverest.

Last reviewed 8 September 2026