1) Constructor: LiftSystem(int floorsCount, int liftCapacity, int maxStops)
- Constraints:
2 ≤ floorsCount ≤ 100
,
1 ≤ liftCapacity ≤ 20
,
1 ≤ maxStops ≤ 10
.
Stop counting rule: For a rider, count the number of distinct floors where the elevator halts after the rider boards, excluding the destination floor and boarding floor. This count must be ≤ maxStops.
LiftSystem(int floorsCount, int liftCapacity, int maxStops)
2 ≤ floorsCount ≤ 100
, 1 ≤ liftCapacity ≤ 20
, 1 ≤ maxStops ≤ 10
. boolean requestPickup( int source, int destination)
true
) or reject (false
) immediately.Config: floorsCount = 30, liftCapacity = 3, maxStops = 2
LiftSystem ls = new LiftSystem(30, 3, 2);
ls.requestPickup(0, 20)
→ truels.requestPickup(10, 15)
→ truels.requestPickup(12, 18)
→ falseReasoning:
Outcome: Third request rejected to preserve existing riders’ stop limits.
Config: floorsCount = 15, liftCapacity = 2, maxStops = 5
LiftSystem ls = new LiftSystem(15, 2, 5);
Method calls:
ls.requestPickup(0, 12)
→ true (UP)ls.requestPickup(1, 11)
→ true (UP)ls.requestPickup(2, 10)
→ false (UP; capacity would hit 3 on segment 2..10)ls.requestPickup(14, 3)
→ true (DOWN; handled on opposite pass, does not clash with UP)Outcome: Third UP request rejected due to capacity; DOWN request accepted independently per the problem’s UP/DOWN non-clash rule.