FunctionRacerProblemsRace

Parking Lot With Spot Sizes

EasyClassesPython, JavaScript, TypeScript, Java, C++

Implement a class ParkingLot with three kinds of spots: "small", "medium" and "large". Write these methods:

park is never called with the plate of a car that is still parked, but a plate may park again after it has left. The tests call the methods in sequence and compare every return value. The expected list holds null for the constructor.

Example 1

ParkingLot(1, 1, 1)
park("A1", "small") returns "small"
park("B2", "small") returns "medium"
park("C3", "medium") returns "large"
park("D4", "large") returns ""
leave("B2") returns "medium"
park("E5", "medium") returns "medium"
free_spots("large") returns 0
leave("ZZ") returns ""

The second small car finds the small spot taken and moves up to the medium spot, which leaves only the large spot for the medium car C3. The large car D4 finds nothing. When B2 leaves, the medium spot is free for E5.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Classes problems