Select the best dasher for an order
DoorDashSoftware Engineer · Online AssessmentLast 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
orderwith a pickup location(x, y). - A list of
dashers, each with: id- current location
(x, y) is_availableboolean
Requirements:
- Only available dashers are eligible.
- Choose the eligible dasher with the smallest Euclidean distance to the pickup location.
- If there is a tie, choose the dasher with the smallest id.
- Return the selected
dasher_id, ornullif none are available.
Task: Implement the selection function and analyze its time complexity.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.