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.
CodingMid-level
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).
Contextos reais
Onde essa pergunta já apareceu
Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.
Ubermidjan. de 2025
Anexos públicos
Materiais associados
Nenhum anexo público associado a esta pergunta.
Sinais de resposta forte
Você deixa claro por que escolheu essa abordagem e o que descartou.
Seu código vem acompanhado de testes mentais e edge cases relevantes.
Sua explicação ajuda o entrevistador a acompanhar o raciocínio em tempo real.
O que costuma enfraquecer a resposta
Entrar direto no código sem alinhar interpretação do problema.
Passar tempo demais em silêncio e só explicar no fim.
Ignorar complexidade, invariantes e estratégia de teste.
Continue a preparação com o banco completo
No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.