PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/DoorDash

Find Each Cell's Nearest Source

Last updated: Apr 12, 2026

Quick Overview

This question evaluates understanding of shortest-path computation and distance labeling in grid-based graphs, measuring competency in algorithmic problem solving and efficient traversal strategies.

  • medium
  • DoorDash
  • Coding & Algorithms
  • Software Engineer

Find Each Cell's Nearest Source

Company: DoorDash

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Given an `m x n` grid containing `1` for source cells and `0` for regular cells, compute for every cell the shortest 4-directional distance to any source cell. Moving up, down, left, or right costs 1 step. Return an `m x n` matrix of distances, where every source cell has distance `0`. If the grid contains no source cells, return `-1` for every cell.

Quick Answer: This question evaluates understanding of shortest-path computation and distance labeling in grid-based graphs, measuring competency in algorithmic problem solving and efficient traversal strategies.

Related Interview 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)
DoorDash logo
DoorDash
Feb 3, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
8
0

Given an m x n grid containing 1 for source cells and 0 for regular cells, compute for every cell the shortest 4-directional distance to any source cell. Moving up, down, left, or right costs 1 step. Return an m x n matrix of distances, where every source cell has distance 0. If the grid contains no source cells, return -1 for every cell.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More DoorDash•More Software Engineer•DoorDash Software Engineer•DoorDash Coding & Algorithms•Software Engineer Coding & Algorithms
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.