Bird
Raised Fist0

If the RandomSpotStrategy is used and the parking lot has 10 free spots, what is the expected behavior when a vehicle arrives?

medium📝 Analysis Q5 of Q15
LLD - Design — Parking Lot System
If the RandomSpotStrategy is used and the parking lot has 10 free spots, what is the expected behavior when a vehicle arrives?
AThe vehicle is assigned the last spot in the list.
BThe vehicle is assigned a random spot among the 10 free spots.
CThe vehicle is assigned the first spot in the list.
DThe vehicle is rejected because random is not supported.
Step-by-Step Solution
Solution:
  1. Step 1: Understand RandomSpotStrategy behavior

    This strategy picks any free spot randomly from available spots.
  2. Step 2: Apply to 10 free spots

    With 10 free spots, the vehicle can get any one of them randomly.
  3. Final Answer:

    The vehicle is assigned a random spot among the 10 free spots. -> Option B
  4. Quick Check:

    Random strategy = random free spot [OK]
Quick Trick: Random strategy picks any free spot [OK]
Common Mistakes:
MISTAKES
  • Assuming first or last spot always assigned
  • Thinking random strategy rejects vehicles
  • Confusing random with nearest

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes