Skip to content

Elevator System — Simple#

Problem statement (interviewer prompt)

Design the control system for a bank of N elevators in a tall building. Model floor calls (up/down), cabin requests, the dispatch algorithm (e.g. nearest-car or zoning), and the elevator's internal state machine. Optimise for waiting time + travel time.

classDiagram
  class ElevatorSystem {
    +cars : List~Car~
    +request(from, to)
    +callFloor(floor, dir)
  }
  class Car {
    +id
    +floor
    +dir : Direction
    +state : State
    +queue
    +move()
  }
  class Dispatcher {
    +assign(req) Car
  }
  ElevatorSystem --> Dispatcher
  ElevatorSystem "1" *-- "many" Car