Rotting Oranges
Recognize the pattern
Brute force idea
The naive version of Rotting Oranges sounds like this: Simulate minute by minute from each rotten orange independently. Re-processes already-rotten oranges. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
Better approach
The real unlock in Rotting Oranges comes when you notice this: Multi-source BFS: start with ALL rotten oranges in the queue simultaneously. Each BFS level = one minute of spreading. Count levels until all fresh oranges are rotten. Instead of recomputing the world every time, you preserve just enough context to let the next decision become obvious.
Key invariant
The compass for Rotting Oranges is this: All rotten oranges spread simultaneously — that's multi-source BFS. Each level of the BFS represents one minute. The number of levels (minus 1) is the answer. As long as that statement keeps holding, you can trust the steps built on top of it.
Watch out for
The trap in Rotting Oranges usually looks like this: Starting BFS from only one rotten orange — all rotten oranges spread in parallel. Initialize the queue with ALL of them. When the code becomes mechanical before the idea is clear, small edge cases start breaking the whole story.