Panda Guru LogoPanda
Guru

Wayfair Machine Coding Practice 4

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 shipmentassignShipment(shipmentId).
3️⃣ Calculate total shipment costcalculateShipmentCost(shipmentId).
4️⃣ Track shipment statustrackShipment(shipmentId).
5️⃣ Update shipment statusupdateShipmentStatus(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.