Round 1
Questions:
Design a Shipment & Package Management System with the following features:
1️⃣ Add a package to the system → addPackage(packageId, weight, distance)
.
2️⃣ Assign packages to a shipment → assignShipment(shipmentId)
.
3️⃣ Calculate total shipment cost → calculateShipmentCost(shipmentId)
.
4️⃣ Track shipment status → trackShipment(shipmentId)
.
5️⃣ Update shipment status → updateShipmentStatus(shipmentId, status)
.
Constraints:
✅ Each shipment has a weight limit of 100 kg.
✅ Packages should be prioritized by weight (heaviest first).
✅ Shipment cost formula:
[
\text{Cost} = \text{$10 (Base Fee)} + (2 \times \text{Total Weight}) + (5 \times \frac{\text{Total Distance}}{100})
]
Candidate's Approach
- Used PriorityQueue (Max Heap) to ensure heaviest packages are assigned first (
O(N log N)
). - Implemented a HashMap for Shipments & Status for quick lookups.
- Followed a Basic OOP Design with a single class implementation for simplicity.
Interviewer's Feedback
No feedback provided.