Infection Simulation in a Grid

Asked at Anthropic · Coding Questions · Difficulty: Medium · Last asked Jun 15, 2026

Given an n*m grid where some cells may be infected. Each healthy cell becomes infected if it has N infected neighbors (up, down, left, right). The problem is to calculate the time taken for all cells to become infected. The initial state and the value of N will be provided.

Loading the problem…