🌱SproutStack
👤 Guest

🌱 DSA (Beginner) · Next Level (Brief) · cozy lesson

Graphs: BFS/DFS 🔒 premium preview

🔒 Marked premium for future. Free while we build locally — payment comes later.

12 min · 1 min read · no scary math, promise

🤖
You’ve got this. Read a little, play a little — I’ll wait. No rush.
def islands(g):
    R,C=len(g),len(g[0]); c=0
    def dfs(r,cc):
        if not (0<=r<R and 0<=cc<C) or g[r][cc]!='1': return
        g[r][cc]='0'
        for dr,dc in [(1,0),(-1,0),(0,1),(0,-1)]: dfs(r+dr,cc+dc)
    for r in range(R):
        for cc in range(C):
            if g[r][cc]=='1': dfs(r,cc); c+=1
    return c

Check your understanding

Correct answers earn XP (once each).

1. Islands count via?

2. BFS for shortest?

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.