Easy · System Design
Design Parking System
Given the numbers of big, medium and small parking spaces and a sequence of addCar(carType) calls (1 = big, 2 = medium, 3 = small), return for each call whether that car can park, that is, whether a space of its own size is still free; parking uses up that space.
Examples
Example 1
{
"big": 1,
"medium": 1,
"small": 0,
"cars": [1, 2, 1, 3]
}Output: [true, true, false, false]
Example 2
{
"big": 1,
"medium": 0,
"small": 2,
"cars": [3, 1, 1, 2, 3, 3]
}Output: [true, true, false, false, true, false]
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.