Preparing your design workspace

Loading the problem and your saved attempt…

Design a Thread-Safe One-Dimensional Parking Lot

Allocate one spot to cars and two consecutive spots to trucks under concurrent park and removal operations.

Design and implement the core of a thread-safe one-dimensional parking lot. A car occupies one spot and a truck occupies two consecutive spots. Multiple callers may park and remove vehicles concurrently, and a working solution is required.

For this exercise, assume each vehicle has a unique ID, a successful park returns one immutable ticket with the assigned contiguous range, repeated park or removal calls return explicit idempotent outcomes, and no caller may observe or create a partially allocated truck.

Prefer the lowest-index compatible range, but keep allocation strategy replaceable. Persistence, payments, reservations, and multiple floors are outside scope.