The Rot Spreads — Solution & Editorial
Multi-source BFS: seed the queue with every rotten cell at time 0; the answer is the largest BFS time, provided no fresh cell is left unvisited.
Complexity: O(NM)
Multi-source BFS: seed the queue with every rotten cell at time 0; the answer is the largest BFS time, provided no fresh cell is left unvisited.
Complexity: O(NM)