Given a grid
grid, where 0 is an empty cell, 1 is a fresh orange, and 2 is a rotten orange. Every minute, rotten oranges infect adjacent fresh oranges (4-directional). Return the minimum number of minutes until no fresh oranges remain, or -1 if impossible.Example 1
Input: grid = [[2,1,1],[0,1,1],[1,0,1]]
Output: -1
Explanation: Fresh orange is unreachable from rotten ones.
Output: -1
Explanation: Fresh orange is unreachable from rotten ones.
Example 2
Input: grid = [[2,1,1],[1,1,0],[0,1,1]]
Output: 4
Explanation: In 4 minutes all fresh oranges rot.
Output: 4
Explanation: In 4 minutes all fresh oranges rot.