Grokking Data Structures & Algorithms for Coding Interviews
0% completed
Stretch Problem: Rotting Oranges (medium)
This problem is optional. The problems above cover what the chapter teaches. This one is here for readers who want a harder queue question, and nothing later in the course depends on it.
Problem Statement
You are given a grid where each cell holds one of three values:
0is an empty cell,1is a fresh orange,2is a rotten orange.
Every minute, a fresh orange that shares a side with a rotten orange becomes rotten. Sharing a side means directly above, below, left or right, never diagonally.
Return the number of minutes until no fresh orange is left
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%