Design an Elevator System
Design a multi-elevator system with sorted stop lists that avoid zig-zagging, a pluggable dispatch strategy, and clear handling of hall calls and car buttons.
The elevator system is the hardest of the classic LLD problems, and also one of the most rewarding to practise. At first it sounds easy: a box goes up and down. But the questions come quickly. Which elevator should answer a call? In which order should it visit the floors? What if people press buttons while it is moving? How do you stop the car from rushing up and down without a plan?
In this lesson we design it with the seven-step method. You will see a simple, effective rule for the movement of one elevator, a strategy for choosing between several, and how the earlier patterns, Strategy in particular, keep the design clean.
01The problem
Design an elevator system for a building with many floors and several elevators. People call an elevator from a floor and choose a destination inside the car.
Loading the rest of the lesson…