Pattern Recognition Drill
Medium Graphs
The Problem
In a grid, fresh oranges rot when adjacent to rotten ones. Find the minimum minutes for all to rot.
What approach would you use?
Think about it before scrolling down.
Add all rotten oranges to queue at time 0. BFS spreading rot. Track max time. O(m*n).
DFS from each rotten orange updating min time — but BFS is cleaner for simultaneous spread.
Common Trap
Don't BFS from one rotten orange at a time — they all spread SIMULTANEOUSLY. Multi-source BFS.