A virus is spreading across an isInfected, where:
isInfected[i][j] = 0 represents an uncontaminated cell.
isInfected[i][j] = 1 represents an infected cell.
A viral region consists of infected cells that are connected
Every day, the following steps occur in order:
The viral region that threatens to contaminate the strictly greatest number of uninfected cells in the upcoming round is quarantined. You build walls along every boundary between infected cells in this region and their adjacent uninfected cells. Once quarantined, this region cannot spread, and its cells can no longer threaten any neighbors.
Every remaining active viral region spreads to all adjacent uninfected cells (
This daily process continues until no new cells can be infected or all viral regions are quarantined.
Return the total number of walls built to contain the virus.
Constraints:
m isInfected.length
n isInfected[i].length
m, n
isInfected[i][j] is either
There is always a contiguous viral region throughout the described process that will infect strictly more uncontaminated squares in the next round.
A virus is spreading across an isInfected, where:
isInfected[i][j] = 0 represents an uncontaminated cell.
isInfected[i][j] = 1 represents an infected cell.
A viral region consists of infected cells that are connected
Every day, the following steps occur in order:
The viral region that threatens to contaminate the strictly greatest number of uninfected cells in the upcoming round is quarantined. You build walls along every boundary between infected cells in this region and their adjacent uninfected cells. Once quarantined, this region cannot spread, and its cells can no longer threaten any neighbors.
Every remaining active viral region spreads to all adjacent uninfected cells (
This daily process continues until no new cells can be infected or all viral regions are quarantined.
Return the total number of walls built to contain the virus.
Constraints:
m isInfected.length
n isInfected[i].length
m, n
isInfected[i][j] is either
There is always a contiguous viral region throughout the described process that will infect strictly more uncontaminated squares in the next round.