Katkat

Select the best dasher for an order

DoorDashSoftware Engineer · Online Assessment

Last updated

This problem evaluates algorithmic selection and geometric computation skills—filtering eligible dashers, calculating Euclidean distances, and applying deterministic tie-breaking—within the Coding & Algorithms domain at an implementation-level algorithmic abstraction.

You need to assign an order to a dasher.

Input:

  • An order with a pickup location (x, y).
  • A list of dashers, each with:
  • id
  • current location (x, y)
  • is_available boolean

Requirements:

  1. Only available dashers are eligible.
  2. Choose the eligible dasher with the smallest Euclidean distance to the pickup location.
  3. If there is a tie, choose the dasher with the smallest id.
  4. Return the selected dasher_id, or null if none are available.

Task: Implement the selection function and analyze its time complexity.