Design a parking lot system that supports parking and removing vehicles. The parking lot has multiple floors. Each floor has a list of parking spots.
Floors are numbered from 0. Spots on each floor are also numbered from 0 from left to right. Initially, all parking spots are empty.
The parking lot should always assign the lowest available valid spot. A lower floor is preferred first. If multiple valid spots are available on the same floor, the spot with the lower index should be assigned first.
A car can only be parked in a car spot.
For a motorcycle, the system should search all floors for the lowest available motorcycle spot first. Only if there is no available motorcycle spot in the entire parking lot, the system should search for the lowest available car spot.
2 means only a motorcycle can be parked at that spot.4 means only a car can be parked at that spot."CAR""MOTORCYCLE"ParkingLot(List<String> parkingFloors)
Each element in parkingFloors represents one floor of the parking lot. The floor index is the index of that element in the list, starting from 0.
Each element is a comma-separated list of integers. The spot index is the position of that integer in the comma-separated list, starting from 0. The comma-separated string will not contain spaces.
For example, "2,4,2" means the floor has three spots: motorcycle spot at index 0, car spot at index 1, and motorcycle spot at index 2.
String parkVehicle(String vehicleId, String vehicleType)
Parks the given vehicle in the lowest available valid spot.
For a car, the system should assign the lowest available car spot.
For a motorcycle, the system should search all floors for the lowest available motorcycle spot first. Only if there is no available motorcycle spot in the entire parking lot, then it should assign the lowest available car spot.
Returns the assigned parking spot in the format: "floor=0,type=CAR,spot=2"
In the returned value, both floor and spot are 0-indexed.
In the returned value, type represents the assigned spot type, not necessarily the vehicle type. For example, if a motorcycle is parked in a car spot, the returned type should be CAR.
Returns "VEHICLE_ALREADY_PARKED" if the vehicle is already parked. Returns "NO_SPOT_AVAILABLE" if no valid spot is available.
String removeVehicle(String vehicleId)
Removes the given vehicle from the parking lot and frees its spot.
Returns the freed parking spot in the format: "floor=0,type=CAR,spot=2"
In the returned value, both floor and spot are 0-indexed.
In the returned value, type represents the freed spot type, not necessarily the vehicle type.
Returns "VEHICLE_NOT_FOUND" if the vehicle is not currently parked.
1 <= parkingFloors.size() <= 10002 or 4.vehicleId is a non-empty string.vehicleType is either "CAR" or "MOTORCYCLE".ParkingLot parkingLot = new ParkingLot(parkingFloors = List.of("2,4", "4,2"));
parkingLot.parkVehicle(vehicleId = "bike1", vehicleType = "MOTORCYCLE") returns "floor=0,type=MOTORCYCLE,spot=0"
parkingLot.parkVehicle(vehicleId = "car1", vehicleType = "CAR") returns "floor=0,type=CAR,spot=1"
parkingLot.parkVehicle(vehicleId = "bike2", vehicleType = "MOTORCYCLE") returns "floor=1,type=MOTORCYCLE,spot=1"
parkingLot.removeVehicle(vehicleId = "bike1") returns "floor=0,type=MOTORCYCLE,spot=0"
ParkingLot parkingLot = new ParkingLot(parkingFloors = List.of("4", "4"));
parkingLot.parkVehicle(vehicleId = "bike1", vehicleType = "MOTORCYCLE") returns "floor=0,type=CAR,spot=0"
parkingLot.parkVehicle(vehicleId = "bike2", vehicleType = "MOTORCYCLE") returns "floor=1,type=CAR,spot=0"
parkingLot.parkVehicle(vehicleId = "car1", vehicleType = "CAR") returns "NO_SPOT_AVAILABLE"