Compute delivery times on a grid
DoorDashSoftware Engineer · Technical ScreenLast updated
This question evaluates understanding of graph traversal and shortest-path algorithms, grid-based pathfinding, and data structure selection for representing sparse or large grids within the Coding & Algorithms domain.
You are given a 2D grid with cells marked as 'M' (warehouses), 'C' (customers), 'X' (obstacles), and '.' (roads). You can move up, down, left, or right with cost 1 per step. For each customer cell, compute the minimum number of steps from any warehouse; return -1 if unreachable. Define the input/output format and justify your data structures. Follow-ups: handle millions of cells efficiently (memory/time); support non-uniform road costs (convert to Dijkstra); and return actual paths for a subset of customers.
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.