← 返回 amazon 的题目列表Implement a Delivery and Collection Algorithm
类型:online_judge
Design a package delivery and collection system. Implement the following features:
Users can request to have packages delivered to specific lockers.
Users can request to collect packages from lockers.
The system should support adding new lockers and checking locker availability.
Implement a data structure that supports efficient delivery and collection operations, and provide code to satisfy these requirements. Provide at least three test cases to verify your system.
Input
A series of string commands, each representing an action:
addLocker() - Add a new locker
deliverPackage(packageId, lockerId) - Deliver package with packageId to locker lockerId
pickupPackage(packageId) - Pickup a package from the locker
Output
Output the result of each operation on a new line.
Constraints
Total number of lockers will not exceed 1000.
Total number of packages will not exceed 10000.
Example
Input
addLocker()
deliverPackage(1, 0)
pickupPackage(1)