#994 - Rotting Oranges
In an m × n grid, each cell can be empty (0), a fresh orange (1), or a rotten orange (2). Every minute, fresh oranges adjacent (4-directionally) to rotten ones become rotten. Return the minimum number of minutes until no fresh orange remains, or -1 if impossible.
| Input | Output |
|---|---|
grid = [[2,1,1],[1,1,0],[0,1,1]] | 4 |
grid = [[2,1,1],[0,1,1],[1,0,1]] | -1 |
grid = [[0,2]] | 0 |