Skip to content

PRO TIP Block youtube.com at the DNS level β€” Pi-hole, NextDNS or your hosts file β€” but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

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