← All problems

Rotting Oranges

Medium graphsbfsmatrix LeetCode ↗
Minutes until no fresh orange remains (4-directional spread per minute); -1 if impossible.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(mn), Space O(mn)

Common pitfalls

  • BFS from each rotten separately (wrong timing)
  • Forgetting the impossible case

Your solution

Log in to save your code and track progress.