Design and Implement a Multi-Entrance Parking Lot
Allocate the nearest compatible spot across several entrances while preventing duplicate parking and releasing spots safely.
For this exercise, assume the following practice scope. Design and implement the in-memory core of a parking lot. The lot has fixed small, medium, and large spots and several entrances. A vehicle has a stable plate ID and size; it may use a spot of equal or larger size but never a smaller one.
park(vehicle, entranceId) assigns the compatible available spot with the shortest configured distance from that entrance, breaking ties by spot ID, and returns a ticket. A vehicle already parked, an unknown entrance, or no compatible spot returns an explicit error without partial mutation.
unpark(ticketId) closes one active ticket and releases exactly its spot; duplicate or unknown unpark calls are rejected deterministically. A vehicle cannot have two active tickets, and one spot cannot belong to two tickets.
Implement park and unpark plus the data structures that support them, state their time complexity, and explain safe simultaneous park calls. Pricing, reservations, persistence, valet workflows, and UI are outside scope.