Description
Design a parking system for a parking lot with big, medium, and small spots. Implement ParkingSystem(big, medium, small) and addCar(carType) that returns true if a spot is available. Return the result as an array.
Examples
big = 1, medium = 1, small = 0, calls = [[1],[2],[3],[1]][true,true,false,false]Lot has 1 big, 1 medium, 0 small spots. addCar(1): big car parks successfully (true). addCar(2): medium car parks (true). addCar(3): no small spots available (false). addCar(1): no big spots left (false).
big = 1, medium = 1, small = 0, calls = [[1]][true]A single parking operation on a lot with 1 big and 1 medium spot.
big = 2, medium = 0, small = 3, calls = [[3],[1],[3],[2],[1],[3]][true,true,true,false,true,true]Initially: 2 big spots, 0 medium spots, 3 small spots. First small car parks (spots: 2,0,2). Big car parks (spots: 1,0,2). Second small car parks (spots: 1,0,1). Medium car fails - no medium spots available. Third big car parks (spots: 0,0,1). Fourth small car parks (spots: 0,0,0). Shows how different car types use their designated spots independently.
Constraints
- •
0 ≤ big, medium, small ≤ 1000