Coding Trainer

Rotting Oranges

MediumBFSLC #994

Problem

Grid with 0=empty, 1=fresh orange, 2=rotten. Each minute, rotten oranges spread to adjacent fresh ones. Return minimum minutes to rot all oranges, or -1 if impossible.

Example: [[2,1,1],[1,1,0],[0,1,1]] → 4