#47 · Does the lift door-close button work?
Most US door-close buttons stopped working after the ADA. Pressing "3" five times is still one request. The SCAN (elevator) algorithm and the LLD "design an elevator" answer.
Ek line yaad rakho: requests ka set, ek direction poori, phir reverse.
The button
After the Americans with Disabilities Act (1990), lift doors must stay open long enough for people using wheelchairs or crutches, so on most US elevators the door-close button does nothing for regular riders (The New York Times, via CBS Boston, 31 Oct 2016). Door-open still works.
Pressing 5 times
The controller stores requests in a set: floor 3 is either requested or not. Duplicates are ignored — the press is idempotent.
Which floor first: SCAN
The lift keeps moving in its current direction and serves every request on the way, then reverses. This is the SCAN / elevator algorithm (also used for disk scheduling). It travels far less than serving requests in arrival order.
Example (illustration): lift at 3, requests arrive 5, 2, 4, 1, 6 → in arrival order it travels 15 floors; with SCAN (up 4, 5, 6, then down 2, 1) only 8.
The interview answer: design an elevator (LLD)
- States: IDLE, MOVING_UP, MOVING_DOWN, DOORS_OPEN (+ MAINTENANCE).
- Requests: hall calls (floor + direction) and car calls (floor), stored as sets per direction.
- Scheduler: SCAN/LOOK per car; with many cars, a dispatcher assigns hall calls to the best car (nearest moving the right way).
- Edge cases: door timer, overload, emergency, fire mode.
Words to say: state machine, request set (idempotent), SCAN/LOOK, dispatcher.
Go deeper
Finished reading?
Mark it done to track your progress in Reels.
#48 · Why your neighbour's TV shouts SIX before your phone
Live streams are cut into segments; players start a few segments behind live. 6 s × 3 = 18 s of buffer alone. Latency vs buffering, and how Low-Latency HLS fixes it.
#46 · How does Uber find the nearest car so fast?
Thousands of cars, and your cab in two seconds. Uber's H3 hexagon grid, k-ring search, and the geospatial index pattern behind "find nearby".