Panda Guru LogoPanda
Guru

Flipkart | SDE 3 | Machine Coding | 120 Minutes

Round 1

Questions: Implement a Peer-to-Peer Delivery System that can be used to deliver a parcel from one customer to another. Below are the expected features of the system:

  1. The system should be able to onboard new customers and drivers.
  2. The list of items that can be delivered is preconfigured in the system and is fixed.
  3. Customers should be able to place an order for the delivery of a parcel and also be able to cancel it.
  4. One driver can pick up only one order at a time.
  5. Orders should be auto-assigned to drivers based on availability. Even if no driver is available, the system should accept the order and assign it to a driver when the driver becomes free. The number of ongoing orders can exceed the number of drivers.
  6. Once an order is assigned to a driver, the driver should be able to pick up the order and also mark the order as delivered after delivery.
  7. The system should be able to show the status of orders and drivers.
  8. Canceled orders shouldn’t be assigned to the driver. If an assigned order gets canceled, the driver shouldn’t be able to pick up the order; the driver should be available for other orders.
  9. Once a driver picks up an order, the order cannot be canceled by the user nor system.
  10. Assume driver is available 24*7. Ignore the travel time.
  11. Ensure application is thread safe and all concurrency scenarios.

Bonus:

Guidelines:

Sample Test cases:

Candidate's Approach

The candidate approached the problem by designing a modular system with classes for Customer, Driver, Order, and DeliveryService. They implemented methods for onboarding customers and drivers, placing and canceling orders, and checking the status of orders and drivers. The candidate ensured thread safety by using synchronized blocks where necessary and handled concurrency scenarios effectively. They also created a mock notification service to simulate email and SMS notifications for order updates.

Interviewer's Feedback

The interviewer appreciated the candidate's modular design and attention to concurrency issues. They noted that the code was clean and well-structured, making it easy to follow. However, they suggested adding more test cases to cover edge cases and improve the robustness of the solution.