Algorithm · Google · Medium
Requirements Given a grid containing source cells—such as taxis, rotten oranges, or gates—determine the distance from each non-source cell to its closest source. A follow-up asks how the design should change when source locations move or vary over time. Discuss whether to rebuild the distances periodically or update them incrementally. Examples In the rotting-oranges version, use [[2,1,1],[1,1,0],[0,1,1]]. Return 4, the number of minutes required for every reachable 1 to…
Checking your access…