FastPrepRotting Orange Propagation
Problems/Rotting Orange Propagation

Rotting Orange Propagation

Indeed logoIndeed● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Indeed phone screen. The report names a Karat BFS task like Rotten Oranges. Our standard spreading exercise is about 70% the same as that reported kind of task. The exact interview change is not known.

Given a rectangular grid, each cell is 0 for empty, 1 for a fresh orange, or 2 for a rotten orange.

For this exercise, assume each minute every orange rotten at the start of that minute infects its fresh neighbors directly above, below, left, and right. All infections in a minute happen simultaneously. Empty cells remain empty and do not transmit rot.

Return the smallest number of minutes until no fresh orange remains. Return -1 if some fresh orange can never rot, and 0 if the input has no fresh oranges.

This is a BFS task similar to Rotten Oranges, with the propagation rules above.

Function

minutesToRot(grid: int[][]) → int

Examples

Example 1

grid = [[2,1],[1,1]]return = 2
grid
01021111

At minute 1 the two neighbors of the corner rot; at minute 2 the opposite corner rots.

Example 2

grid = [[2,1,0,1]]return = -1
grid
012302101

The empty cell blocks the route to the final fresh orange.

Example 3

grid = [[0,2]]return = 0
grid
01002

No fresh orange is present, so no time is needed.

Constraints

  • For this exercise, assume an empty grid is allowed. Otherwise there are 1 through 20 rows and columns, and every row has the same length.
  • Every cell is one of 0, 1, or 2.

More Indeed Phone Screen questions

  • Insert into an Unrolled Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Course Completion OrderPHONE SCREEN · Seen May 2025
  • Recipes You Can PreparePHONE SCREEN · Seen May 2025
  • Courses Shared by Every Student PairPHONE SCREEN · Seen Aug 2022
  • First and Last Access Time per UserPHONE SCREEN · Seen Jul 2022
  • Most Accessed Resource in Five MinutesPHONE SCREEN · Seen Jul 2022
  • Resource Transition GraphPHONE SCREEN · Seen Jul 2022
  • Count Disappearing Connected TilesPHONE SCREEN · Seen Jul 2022
  • First Dictionary Word from Note LettersPHONE SCREEN · Seen Jul 2022
  • Word Path Moving Only Right or DownPHONE SCREEN · Seen Jul 2022

Similar questions at other companies

  • Matrix EscapeByteDance · PHONE SCREENByteDance interview questions
  • Minimum Time to Spread Through a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Max Area of Island Without Changing the GridFlexport · PHONE SCREENFlexport interview questions
  • Reachable Exits in an Obstacle GridWhatNot · PHONE SCREENWhatNot interview questions
  • Process Minesweeper Game OperationsAmperity · PHONE SCREENAmperity interview questions
  • Count Islands in a Binary GridApple · PHONE SCREENApple interview questions
  • Find and Reconstruct a Binary-Matrix PathMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Pacific Atlantic Water FlowAnduril · PHONE SCREENAnduril interview questions
  • Fuel-Aware Grid ReachabilityBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • House Bounds in a Ragged GridRippling · OA · PHONE SCREENRippling interview questions

Indeed interview experiences

  • Indeed Experienced SWE Karat Screens and OAs: 6 Experiences
  • Indeed SWE Intern Karat Screens and OA: 3 Experiences
  • Indeed New Grad SWE Online Assessments: 3 Experiences
All Indeed interview questionsSee Indeed hiring insights
Saved
class Solution {
    public int minutesToRot(int[][] grid) {
        // Write your code here.
        return 0;
    }
}
Checking account…