As reported: Autodesk Pune Software Engineer loop (C++, 2026), round 1: Rotting Oranges, after a level-order tree traversal.
This is LeetCode 994 — Rotting Oranges.
You are given an m × n grid where each cell is 0 (empty), 1 (a fresh orange) or 2 (a rotten orange). Every minute, each fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten.
Return the minimum number of minutes until no cell has a fresh orange. If that is impossible, return -1.
Example 1
grid = [[2,1,1],[1,1,0],[0,1,1]] -> 4
Example 2
grid = [[2,1,1],[0,1,1],[1,0,1]] -> -1
The bottom-left orange is never next to a rotten one.
Example 3
grid = [[0,2]] -> 0
No fresh oranges at minute 0.
Constraints: 1 ≤ m, n ≤ 10; grid[i][j] is 0, 1 or 2.
Code runner format: one line holding grid (LeetCode's test-case format). Implement orangesRotting(grid); the harness prints the number of minutes.