Bird
0
0

In a system with multiple elevators, how can the Elevator class be designed to efficiently handle requests from different floors?

hard📝 Trade-off Q9 of 15
LLD - Design — Elevator System
In a system with multiple elevators, how can the Elevator class be designed to efficiently handle requests from different floors?
AUse a static variable to store all requests globally without elevator context
BMaintain a queue of requests and implement logic to pick the nearest request
COnly serve requests from the ground floor
DIgnore requests and move randomly between floors
Step-by-Step Solution
Solution:
  1. Step 1: Understand multi-elevator request handling

    Each elevator should track requests and decide which to serve next.
  2. Step 2: Efficient design

    Using a queue and nearest request logic optimizes elevator movement and reduces wait time.
  3. Final Answer:

    Maintain a queue of requests and implement logic to pick the nearest request -> Option B
  4. Quick Check:

    Queue + nearest request logic = efficient handling [OK]
Quick Trick: Use queues and nearest request logic for multi-elevator systems [OK]
Common Mistakes:
MISTAKES
  • Ignoring request order
  • Random movement
  • Static global request storage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes