O42
Rotting Oranges (Multi-Source BFS)
Problem Statement & Objective
You are given an m x n grid containing fresh and rotten oranges. Return the minimum number of minutes that must elapse until no cell has a fresh orange.
Function Signature (Python)
rotting_oranges_multisource_bfs(grid: list[list[int]]) -> intInput & Output Contract
Output Rule:Minimum dakika veya -1.
System Constraints
m == izgara.length, n == izgara[i].length
1 <= m, n <= 10
izgara[i][j] ∈ {0, 1, 2}Example Execution Walkthrough
izgara = [[2, 1, 1], [1, 1, 0], [0, 1, 1]] -> 4 dakika
izgara = [[2, 1, 1], [0, 1, 1], [1, 0, 1]] -> sol alttaki taze portakala ulaşılamaz -> -1Example Test Scenarios (3)
Example 1
Input:
[[[2,1,1],[1,1,0],[0,1,1]]]Expected Output:
4Example 2: Ulaşılamaz
Input:
[[[2,1,1],[0,1,1],[1,0,1]]]Expected Output:
-1Example 3: Taze Yok
Input:
[[[0,2]]]Expected Output:
0