Skip to content

#994 - Rotting Oranges

MediumGraphs - BFS
Open on LeetCode

In an m × n grid, each cell can be empty (0), a fresh orange (1), or a rotten orange (2). Every minute, fresh oranges adjacent (4-directionally) to rotten ones become rotten. Return the minimum number of minutes until no fresh orange remains, or -1 if impossible.

InputOutput
grid = [[2,1,1],[1,1,0],[0,1,1]]4
grid = [[2,1,1],[0,1,1],[1,0,1]]-1
grid = [[0,2]]0

Released under the MIT License.