Given a matrix of integers A of size N x M consisting of 0, 1 or 2.
Each cell can have three values:
Every minute, any fresh orange that is adjacent (Left, Right, Top, or Bottom) to a rotten orange becomes rotten.
Return the minimum number of minutes that must elapse until no cell has a fresh orange.
If this is impossible, return -1 instead.
The first argument given is the integer matrix A.
Return the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, return -1 instead.
1 <= N, M <= 1000 0 <= A[i] <= 2
Input 1: A = [ [2, 1, 1] [1, 1, 0] [0, 1, 1] ] Output 1: 4 Input 2: A = [ [2, 1, 1] [0, 1, 1] [1, 0, 1] ] Output 2: -1
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.