LeetCode: https://leetcode.com/problems/rotting-oranges/
You are given an m x n grid where:
0= empty1= fresh orange2= rotten orange
Every minute, fresh oranges adjacent to rotten oranges become rotten. Return the minimum minutes needed, or -1 if impossible.
Example:
- Input:
grid = [[2,1,1],[1,1,0],[0,1,1]] - Output:
4
2
1
1
1
1
0
0
1
1
minutes=0
fresh=6
Step 1 / 3
Step 1:
Initialize the BFS frontier with all rotten oranges and count fresh ones.
Focus: select @ [0]
minutes=0fresh=6