Given a Matrix of order M*N, where each cell can have zero or one orange. The orange in the cell (if present) can be either fresh or rotten. A rotten orange will rot the fresh oranges in the nearby cell in unit time. If a rotten orange is in cell (i,j), then it will rot the fresh oranges present in cells

(i+1, j) (i-1, j) (i, j+1) (i, j-1)

in unit time (say one minute). If a fresh orange is surrounded by all empty cells then it cannot be rotten at all. Given the below matrix Continue reading »