Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
All rotten oranges act as Level 0 and spread rot outward together each minute. Use BFS with time per cell.
BFS frontier guarantees all oranges at the same distance from initial rotten oranges rot at the same minute; the final time is the maximum infection layer.
Updated Feb 2026