Grid Infection with Recovery After D Days
Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem.
Problem
Grid Infection with Recovery After D Days (Become Immune)
Building on (2), add recovery:
Each infected cell 'X' recovers after D days since it got infected and becomes immune 'I' at the end of that day.
Immune 'I' can never be infected and does not infect others.
A healthy '.' becomes infected 'X' at the end of a day if it has at least T infected 'X' neighbors among its 8 neighbors.
Return the number of days until the grid becomes stable, defined as: there are no infected 'X' cells left.
Updates are synchronous. You must track infection age per cell.
Example
Input
3 3
1 1
.X.
...
Output
2
Complete solveGridInfectionRecoveryAfterDays. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters.
input = "3 3\n1 1\n.X.\n...\n..." return = ["2"]
The returned string array must match the expected standard output lines for the sample input.
Use the limits and requirements stated in the prompt.
- Grid Infection Spread Until StablePHONE SCREEN · Seen May 2026
- Grid Infection with Immune Cells Until StablePHONE SCREEN · Seen May 2026
- Infection Spread / Cellular AutomataPHONE SCREEN · Seen May 2026
- Chat Event Counts in Recent WindowPHONE SCREEN · Seen May 2026
- ChatApp with BotsPHONE SCREEN · Seen May 2026
- IP Address to CIDR BlocksPHONE SCREEN · Seen May 2026
- Count Valid SequencesSeen Jan 2025
- Maximize The HitsSeen Sep 2024
public String[] solveGridInfectionRecoveryAfterDays(String input) {
// write your code here
}