Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Rotting Oranges

Medium Queue

In an R x C grid, 0 is an empty cell, 1 is a fresh orange and 2 is a rotten orange. Every minute, each fresh orange that is 4-directionally adjacent to a rotten one becomes rotten. Print the minimum minutes until no fresh orange remains, or -1 if that is impossible.

Constraints

1 <= R, C <= 10 Each cell is 0, 1 or 2

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.