Design an elevator system
HardConceptClassic LLD Problems
Answer
Model a building with several elevators that serve hall calls (up or down buttons on each floor) and car calls (floor buttons inside a car). The central problem is dispatching: choosing which elevator answers each request and in what order each car visits floors.
- Core classes:
ElevatorSystem,ElevatorController,ElevatorCarwith its current floor,DirectionandStateenums,Request, andButtonandDisplaycomponents. - Dispatching: a
DispatchStrategypicks the car, for example the nearest idle car or one already moving towards the floor in the requested direction. - Movement: each car follows the LOOK algorithm, serving every stop in its current direction (kept in sorted sets) before reversing, which avoids starvation.
- Concerns: thread-safe request queues, door and weight safety, and maintenance or emergency modes.
More in Classic LLD Problems
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Design a parking lot system | Concept | Medium | Read the answer to Design a parking lot system | |||
| 2 | Design a vending machine | Concept | Medium | Read the answer to Design a vending machine | |||
| 3 | Design an elevator system | Concept | Hard | Read the answer to Design an elevator system | |||
| 4 | Design a movie ticket booking system | Concept | Hard | Read the answer to Design a movie ticket booking system |