🌱 DSA (Beginner) · Next Level (Brief) · cozy lesson
Matrix BFS: Rotting Oranges 🔒 premium preview
🔒 Marked premium for future. Free while we build locally — payment comes later.
11 min · 1 min read · no scary math, promise
🤖
You’ve got this. Read a little, play a little — I’ll wait. No rush.
from collections import deque
def oranges(g):
q = deque([(r,c) for r in range(len(g)) for c in range(len(g[0])) if g[r][c]==2])
mins, fresh = 0, sum(v==1 for row in g for v in row)
# standard level BFS...
return mins if fresh==0 else -1
Pattern: walls-and-gates, shortest bridge — same multi-source idea.
💛 Enjoying? Try 5 playful quizzes or watch it move.
Check your understanding
Correct answers earn XP (once each).
1. Start BFS from…
2. Fresh left at end?
My notes (saved in this browser)
Select text above → Save selection, or write your own. AlgoMaster-style notebook, local-first for MVP.
No notes yet. Your highlights will live here.
Finished reading? Seal it with a tick ✅
The checkbox in the explorer turns green too — same progress.