Back to problems

Infection Spread Time on a Grid

Algorithm · Airbnb · Medium

A grid with m rows and n columns is composed of cells containing one of three values: 0: a blocked cell that can never become infected. 1: a susceptible cell that can become infected. 2: an already infected cell. Time passes in whole minutes. During each minute, a susceptible cell becomes infected if at least one of its four side-adjacent neighbors (up, down, left, right) is infected. All infections that are possible at the start of that minute occur simultaneously. Return…

Checking your access…