Company: urban_29july
Difficulty: medium
Rotten Oranges Problem Description A storage area is laid out as a grid with N rows and M columns. Every cell holds exactly one of the following: 0 - an empty cell 1 - a fresh orange 2 - a rotten orange Every minute, each orange that is already rotten at the start of that minute causes the fresh oranges in the four cells directly adjacent to it - up, down, left and right - to become rotten. All of this happens at the same time across the whole grid: an orange that turns rotten during a minute only starts affecting its own neighbours in the next minute. Empty cells never become rotten and never pass rot from one side to the other. Determine the number of minutes that pass until no fresh orange is left. If at least one fresh orange can never become rotten, the answer is -1 . Function Description Implement the function minTimeToRottenOranges . Parameters: N - the number of rows in the grid M - the number of columns in the grid grid - the N x M matrix, where every element is 0 , 1 or 2 Ret