← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
In a given grid representing a field of oranges, each cell can be one of three states:
0: Empty cell1: Fresh orange2: Rotten orangeEvery minute, any fresh orange that is adjacent (up, down, left, right) to a rotten orange will also become rotten.
Return the minimum number of minutes required to rot all the fresh oranges. If it's impossible, return -1 instead.
Input: grid = [[2,1,1],[1,1,0],[0,1,1]] Output: 4
Input: grid = [[2,1,1],[0,1,1],[1,0,1]] Output: -1
Input: grid = [[0,2],[1,1]] Output: 0
m == grid.lengthn == grid[i].length1 <= m, n <= 10^4grid[i][j] will be 0, 1, or 2.-1.NOT_FOUND