Infection Spread Time
Medium · Infection Spread Time
Computers in a room are laid out as an m × n grid `field`. Each cell holds one of three values: - `0`: the spot is empty; - `1`: a healthy computer; - `2`: an infected computer. Every minute the virus jumps from each infected computer to its healthy neighbours above, below, left and right (not diagonally). Return how many minutes pass until no healthy computer is left. If some computer can never be infected, return -1.…
Solve the problem →