Search⌘ K
AI Features

DIY: Rotting Oranges

Explore how to solve the Rotting Oranges problem by simulating the spread of rot through a grid. Understand the algorithm to calculate the minimum time until all fresh oranges become rotten or identify when some remain fresh. This lesson strengthens your ability to approach network-based coding challenges in interviews.

Problem Statement

You are given an m * n grid. Each cell in the grid contains one of the three values: [0, 1, 2]. Each value represents the following:

  • 0 represents an empty cell.
  • 1 represents a fresh orange.
  • 2 represents a rotten orange.

A fresh orange, represented by a 1 in the grid, will be rotten if it is four dir ...