DoorDash Coding Interview: Dasher Hub Distances

Based on a candidate's reported DoorDash interview

The interviewer opens

Welcome, and thanks for joining this interview for the Senior Software Engineer role at DoorDash. We'll work through one coding problem together, and I'd like you to think out loud as you code. If you need to step out or take a break, you can pause the interview anytime with the Pause button at the top right.

The problem is about finding walking distances through a floor plan to a single Dasher pickup gate, the kind of routing thinking that matters for delivery logistics. It's up in the Problem tab now, so please read it through and ask me any questions before you start.

The problem

A floor plan marks walls, rooms and a single Dasher pickup gate; fill every room with its walking distance to the gate.

  • rooms: an m x n grid of ints where -1 is a wall, 0 is the gate, and 2147483647 is an empty room.

The grid contains exactly one gate. Moving one step up, down, left or right between non-wall cells costs 1. Return the grid with each empty room replaced by its shortest walking distance to the gate; rooms that cannot reach the gate keep 2147483647. Walls and the gate are unchanged.

Example: rooms = [[INF,-1,0,INF],[INF,INF,INF,-1],[INF,-1,INF,-1],[INF,-1,INF,INF]] (INF = 2147483647) → [[4,-1,0,1],[3,2,1,-1],[4,-1,2,-1],[5,-1,3,4]]

1 ≤ m, n ≤ 250.