Rotting oranges: time for an infection to cover a grid

0
Remix

A grid has empty cells, healthy cells and infected cells. Every minute each infected cell infects its healthy neighbors up, down, left and right. Return the minutes until no healthy cell is left, or -1 if some never get infected. Run a breadth-first search from all infected cells at once. Follow-up: infection also spreads diagonally.

AirbnbCodingLast asked Mar 2026
No answer yet. Write the first one; the best answer gets endorsed.