Rotting Oranges
Medium
Graphs
Array
BFS
Matrix
Grid: 0=empty, 1=fresh, 2=rotten. Each minute rotten spreads to adjacent fresh. Min minutes?
Constraints
m, n ≤ 10
Examples
Example 1:
Input: 2 1 1
1 1 0
0 1 1
Output: 4
Example 2:
Input: 2 1 1
0 1 1
1 0 1
Output: -1
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console