I own a parking garage that provides valet parking service.
There are three types of parking spots:
- small
- medium
- large
Cars also come in three sizes:
- small
- medium
- large
Rules:
- A small car can fit in any spot
- A medium car can fit in medium or large spots
- A large car can fit only in large spots
You receive a stream of parking events.
Each event is either:
"arrival"with a car size"departure"with the same car size (the car leaves and frees its spot)
Your system must assign a valid spot on arrival and free the spot on departure.
Example input (conceptual):
(arrival, small)
(arrival, large)
(arrival, medium)
(departure, small)
(arrival, large)
...
You need to design a system (API + data structure) that correctly handles spot assignment and freeing while following the size rules.
Maintain three counters (available small/medium/large spots).
On arrival, pick the smallest valid spot for that car type.
On departure, restore availability for the spot type previously assigned to that car.
Track active assignments in a map: car_id → spot_type.
The VOprep team has long accompanied candidates through various major company OAs and VOs, including Google, Amazon, Citadel, SIG, providing real-time voice assistance, remote practice, and interview pacing reminders to help you stay smooth during critical moments. If you are preparing for these companies, you can check out our customized support plans—from coding interviews to system design, we offer full guidance to help you succeed.