Given a network of computers represented by an m x n matrix. Computers are either turned off (0), turned on (1) or infected by a virus (-1). Only turned on computers can get infected. Every hour, the neighboring computers of infected computer will get infected. Find the minimum number of hours at which the network will get completely infected. If that cannot happen, return -1. There may be more than one infected computers to start with.
Leetcode 749. Contain Virus
Simulate days on an m×n grid where infected cells spread 4-directionally: each day identify all connected infected regions, compute for each the set of uninfected cells it would infect and the walls required to quarantine it, then greedily build walls around the region that threatens the most cells and let the others spread. Return the total number of walls built until no region can spread (or the grid becomes fully infected).
Onde essa pergunta já apareceu
Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.
Materiais associados
Nenhum anexo público associado a esta pergunta.
Depois de treinar essa pergunta, vale abrir outras do mesmo tipo e da mesma senioridade para comparar padrões de resposta.
Isso ajuda a sair da memorização de uma resposta só e entrar em repertório real de entrevista.
Continue a preparação com o banco completo
No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.