Algorithm · Uber · Medium
Rotting Oranges You receive an m x n grid whose cells use 0 for empty space, 1 for a fresh orange, and 2 for an orange that has already spoiled. At each one-minute interval, every fresh orange sharing an edge with a rotten orange becomes rotten as well. Determine the fewest minutes required for all oranges to become rotten, returning -1 when some orange can never be reached. Examples Example 1: Input: grid = [[2,1,1],[1,1,0],[0,1,1]] Output: 4 The oranges spread through the…
Checking your access…