DSA with Python – Rotting Oranges | BFS Grid Traversal | Leetcode 994 – Part 122 [Hindi]
5.9K views on YouTube
π Welcome to Part 122 of Code & Debugβs DSA Python Course 2025!
In this lecture, we solve Leetcode 994: Rotting Oranges, a popular grid-based problem using Multi-Source BFS. We simulate the rotting process minute-by-minute while spreading the rot to adjacent fresh oranges.
π What youβll learn in this video:
β
Understanding the grid structure and orange states
β
What is Multi-Source BFS and why itβs perfect for this problem
β
BFS traversal with (i, j) β (iΒ±1, jΒ±1) 4-directional movement
β
Keeping track of fresh orange count and time (minutes)
β
Handling edge cases and when to return -1
π‘ Why is this important?
This problem is widely asked in interviews to test BFS traversal in 2D matrices, especially multi-point propagation problems like infection spread, water fill, and shortest distance to resources.
π Practice the problem on Leetcode:
π https://leetcode.com/problems/rotting-oranges/
π Refer to the article for better understanding:
π https://codeanddebug.in/blog/rotting-oranges-leetcode-994/
π π Access the full YouTube DSA Playlist Sheet (All Questions in Order):
π https://docs.google.com/spreadsheets/d/1AWE15Fy3wD2iqu2vjK_R7cCiuvSsjYQclcdZmHpF66o/edit?usp=sharing
π Enroll in this FREE DSA Python course here:
π https://codeanddebug.in/course/master-dsa-with-leetcode
π Enroll for Self-Paced Advanced DSA course here:
π https://codeanddebug.in/course/zero-to-hero-python-dsa
π Thank you for supporting Code & Debug! Donβt forget to like, share, and subscribe to our channel. Hit the π bell icon to stay updated with our latest lectures.
#RottingOranges #GridBFS #MultiSourceBFS #Leetcode994 #MatrixTraversal #PythonDSA #DSAPythonCourse #CodeAndDebug #DSA2025 #CodingInterviews #Part122