Parking Lot Simulator - Problem
Design a parking lot management system that can handle multiple floors and parking spots. The system should support basic operations like parking a vehicle, removing a vehicle, and finding where a vehicle is parked.
Your system should handle the following operations:
- park(vehicle_id): Park a vehicle and return the assigned spot location
- unpark(vehicle_id): Remove a vehicle from its parking spot
- find_vehicle(vehicle_id): Find the location of a parked vehicle
The parking lot has a fixed number of floors and spots per floor. Vehicles should be assigned to the first available spot starting from floor 0, spot 0.
Return the results of all operations as a list of strings, where each string represents the result of the corresponding operation.
Input & Output
Example 1 — Basic Parking Operations
$
Input:
floors = 2, spots_per_floor = 2, operations = ["park A1", "park B2", "find_vehicle A1", "unpark A1", "park C3"]
›
Output:
["Floor 0, Spot 0", "Floor 0, Spot 1", "Floor 0, Spot 0", "Vehicle A1 removed", "Floor 0, Spot 0"]
💡 Note:
A1 parks at first spot (0,0), B2 at (0,1), finding A1 returns (0,0), after unparking A1 that spot becomes available for C3
Example 2 — Full Floor Scenario
$
Input:
floors = 2, spots_per_floor = 1, operations = ["park X1", "park Y2", "park Z3"]
›
Output:
["Floor 0, Spot 0", "Floor 1, Spot 0", "No available spots"]
💡 Note:
First two cars fill both floors (each has 1 spot), third car cannot be parked
Example 3 — Vehicle Not Found
$
Input:
floors = 1, spots_per_floor = 2, operations = ["find_vehicle X1", "unpark Y2"]
›
Output:
["Vehicle not found", "Vehicle not found"]
💡 Note:
Both operations fail because no vehicles are parked yet
Constraints
- 1 ≤ floors ≤ 100
- 1 ≤ spots_per_floor ≤ 100
- 1 ≤ operations.length ≤ 1000
- Vehicle IDs are unique strings of length 1-10
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code