Round 2 - LLD Round
Questions: Elevator LLD Problem: A building with 50 floors. You have a lift which can take 20 people at a go. The lift can stop at any number of floors but for any person who is being served by the lift has to reach from entry floor to destination floor within 5 stops. A lift will serve a new request only if it can maintain the rule of 5 stops for people who are already in the lift and also for the person sending the request.
This is an example case where A, B, C, D, E, F are denoting persons and corresponding values are source and destination floors:
- A: 0 to 10
- B: 1 to 9
- C: 1 to 8
- D: 1 to 7
- E: 1 to 5
- F: 7 to 10
For this case, if Person A is entering at level 0 then the elevator can stop at 1 and it can serve Person B, C, D, and also Person F. As from going level 0 to 10, it will stop at a maximum of 5 places till reaching level 10 (floors on which it will stop will be 1, 7, 8, 9, 10).
Mainly, the discussion was around the algorithm for the given constraint like the elevator should not stop more than 5 stops while serving one person. Currently, consider only one lift in one building.
Which data structure and which optimal strategy will you use to solve this problem? Any thoughts?
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.