advanced 2 min answer

A delivery platform assigns each order to the nearest available driver as soon as the order is ready. Critique this.

doordashoptimisationmatchinglatency
Show the full answer Hide the answer

What the interviewer is testing

Whether you recognise that greedy assignment on a contended resource leaves substantial value unclaimed.

The critique

Greedy is locally optimal and globally poor, because each assignment consumes a resource that later assignments need.

Assigning the nearest driver to order A may strand order B with no driver nearby. It cannot batch two deliveries heading the same way. It ignores how long food will wait, which is a quality problem that greedy assignment cannot see. And it does not consider where drivers end up, so the network drifts out of position relative to where the next wave of demand will appear.

The alternative

Batch over a short window and solve as an optimisation. Consider the orders and drivers available in the window together, and choose an assignment optimising a combined objective: delivery time, driver utilisation, food freshness, and resulting supply positioning.

This requires supporting predictions — restaurant preparation time, travel time under current conditions, and expected demand — each of which is a model with its own accuracy and failure modes.

The trade-off to state explicitly

Waiting to batch adds latency. A decision deferred even briefly improves the assignment and delays the delivery. That window is a tuned parameter balancing global efficiency against individual experience, and it is a product decision as much as a technical one.

Optimisation is also computationally bounded — it must complete within the window at scale, which constrains how sophisticated the objective can be. And it is far harder to explain: when a driver asks why they were not given the nearest order, "an optimiser decided" has real consequences for trust.

What a strong answer adds

The generalisation, which is the point of the question: greedy local decisions produce poor global outcomes whenever resources are contended. The same shape appears in scheduling jobs onto compute, assigning support tickets, placing replicas across nodes, and allocating inventory across warehouses.

The diagnostic question for any assignment problem: is each decision independent, or does it consume something another decision needs? If the latter, greedy is leaving value on the table and the batching window is the dial between responsiveness and efficiency.

Common weak answers

Optimising the distance calculation. Adding more drivers, which addresses supply rather than allocation.