A parking lot is needed with the following requirements:
1. Approx 30 thousand parking slots.
2. Multiple entries and exit points (suppose 4 )
3. The ticket should be generated for the closest free slot from that entry point.
Extension of the problem:
There are also lifts(suppose 2) are present in the parking lot. In case of a conflict give priority to the slots which are closer to the lift. (It's an open-ended problem with not much specification). Also, parking slots (small, medium, large) for bikes, cars, etc. can be incorporated later.
The approach I thought:
Maintain min-heap for empty slots to give the closest slot at each entry. There will be a concurrency issue so a lock can be put on all the entry points. Problem is that it will be slow. and inefficient.
Is there any other and better data structure and approach to store the parking slots and allot them to the coming vehicles for the primary 3 requirements and later for the extension of the problem?
Aucun commentaire:
Enregistrer un commentaire