Question
A rectangular grid contains empty cells (`0`), fresh items (`1`), and contaminated items (`2`). At each minute, every fresh item sharing an edge with a contaminated item becomes contaminated. All changes within a minute occur simultaneously. Implement: ```python def minutes_to_rot(grid: list[list[int]]) -> int: ... ``` Return the number of minutes required for every fresh item to become contaminated. Return `0` if there are no fresh items initially, and `-1` if at least one fresh item is unreachable. Diagonal neighbors do not interact. Aim for `O(rows * columns)` time and space. ## Staged follow-ups 1. Return the earliest arrival time for every reachable cell from multiple sources. 2. Introduce blocked cells and targets, returning the time when all targets are reached. 3. You may remove at most one shared blocker for the entire propagation. Find the best blocker to remove. 4. Discuss incremental updates when sources move over time.