In a grid, 0 is empty, 1 a fresh orange and 2 a rotten one. Each minute, fresh oranges next to (up/down/left/right) a rotten one rot. Return the minutes until no fresh orange remains, or -1 if some can never rot.
Use multi-source BFS: start the queue with every rotten orange at once. Don't modify the input grid.