Algorithm · DoorDash · Medium
You are given a 2D integer array grid with m rows and n columns. A cell value of 1 marks a source cell, while 0 marks an ordinary traversable cell. For every cell, compute the minimum number of moves required to reach some source cell. From any cell, you may move one step north, south, east, or west, and each move costs 1. Every source cell has distance 0. Return a 2D result with the same dimensions as grid, where each entry is the shortest distance to a source. If the grid…
Checking your access…