Zero initial capacity
A lot that starts at capacity 0 rejects every car of that type immediately.
A multi-level parking garage reserves separate floors for big vehicles, medium sedans, and compact cars — each with a fixed number of spots. When a vehicle arrives, the attendant checks that floor's counter: if a spot remains, park and decrement; otherwise, turn the vehicle away. Three counters, one decrement per arrival, one comparison per query. O(1) per operation.
Each car type maps to exactly one counter. A big car cannot take a medium slot. The system is three independent decrement-or-reject counters — no cross-type borrowing.
The common mistake is using a boolean "has space" flag instead of an integer count. A boolean forgets that capacity can be greater than one.
Three independent counters, each decremented on arrival. No search, no sorting — just an array lookup and a decrement.
Store three counters — big, medium, small — set to the capacity of each lot.
On each addCar(type) call, check the counter for the given type.
If the counter is positive, decrement it and return true. Otherwise return false.
Understanding boundary behavior is as important as the main algorithm path.
A lot that starts at capacity 0 rejects every car of that type immediately.
One lot may be full while others have space. Each type is tracked independently.
Time: O(1) per AddCar — single array lookup and decrement.
Space: O(1) — three integer counters.