Solution: Rotting Oranges
Let’s solve the Rotting Oranges problem using the Breadth-first Search pattern.
We'll cover the following...
We'll cover the following...
Statement
Consider an
, which indicates an unoccupied cell. , representing a freshly picked orange. , indicating a rotten orange.
Any fresh orange that is 4–directionally adjacent to a rotten orange will also turn rotten with each passing minute.
Your task is to determine the minimum time required for all cells to have rotten oranges. In case, this objective cannot be achieved, return
Constraints:
m
grid.length
n
...