GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesRotting Fruit Crate

Gamified challenge · Breadth-first search

Rotting Fruit Crate

crate[r][c] is one slot of a crate: 0 is an empty slot, 1 is fresh fruit and 2 is rotten fruit. Every minute, each fresh fruit that touches a rotten fruit up, down, left or right turns rotten. Rot can't cross empty slots or go diagonally.

Write minutesToRot(crate) (Python: minutes_to_rot(crate)) that returns the number of minutes until no fresh fruit is left. Return 0 if there is no fresh fruit at the start, and -1 if some fresh fruit can never be reached by rot.

For [[2, 1, 1], [1, 1, 0], [0, 1, 1]] the rot spreads from the top-left corner and the last fruit (bottom-right) goes bad after 4 minutes.

Sign in to play Rotting Fruit Crate

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account