PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

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.

  • medium
  • DoorDash
  • Coding & Algorithms
  • Software Engineer

Select the best dasher for an order

Company: DoorDash

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

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.

Quick Answer: 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 the best available dasher. The order is represented by its pickup location `(x, y)`. Each dasher is represented as a tuple `(id, x, y, is_available)`, where `id` is the dasher's unique identifier, `(x, y)` is the dasher's current location, and `is_available` indicates whether the dasher can take the order. Choose only from available dashers. Among them, select the dasher with the smallest Euclidean distance to the order's pickup location. If multiple dashers are tied at the same distance, return the one with the smallest `id`. Return the selected `dasher_id`, or `None` if no dashers are available.

Constraints

  • 0 <= len(dashers) <= 100000
  • -1000000 <= x, y <= 1000000
  • Each dasher is represented as `(id, x, y, is_available)`
  • Dasher ids are unique integers

Examples

Input: ((3, 4), [(1, 0, 0, True), (2, 2, 2, True), (3, 10, 10, False)])

Expected Output: 2

Explanation: Available dashers are 1 and 2. Their squared distances to (3, 4) are 25 and 5, so dasher 2 is the closest.

Input: ((0, 0), [(5, 3, 4, True), (2, -3, -4, True), (8, 1, 1, False)])

Expected Output: 2

Explanation: Dashers 5 and 2 are both available and both have squared distance 25 from the pickup point. The tie is broken by smaller id, so return 2.

Input: ((1, 1), [(10, 0, 0, False), (11, 2, 2, False)])

Expected Output: None

Explanation: No dashers are available, so the result is None.

Input: ((7, -2), [])

Expected Output: None

Explanation: The dasher list is empty, so there is no eligible dasher.

Input: ((-1, -1), [(7, -1, -1, True)])

Expected Output: 7

Explanation: The only dasher is available and already at the pickup location, so return id 7.

Hints

  1. You do not need to compute the actual square root for Euclidean distance. Comparing squared distances gives the same ordering.
  2. Track the current best available dasher while scanning the list once, and apply the id tie-break rule when distances are equal.
Last updated: May 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Maximize Chef Assignment Profit - DoorDash (medium)
  • Compute Courier Delivery Pay - DoorDash (easy)
  • Compute Nearest Destination Distances - DoorDash (easy)
  • Compute Driver Pay with Double-Pay Windows - DoorDash (medium)
  • Count changed nodes between two menu trees - DoorDash (hard)