Skip to main content

Practice · 6 of 6

Clinic: The Stack Avalanche

CHALLENGE
Difficulty: advanced+25 XP

**Bài toán.** Undirected graph, n ≤ 200000 (may be a single path); count connected components. **The submission below uses recursive DFS — Runtime Error (stack overflow) on a long path.** Fix it to survive the chain. ``cpp function<void(int)> dfs = [&](int u) { vis[u]=1; for (int v: g[u]) if (!vis[v]) dfs(v); }; ``

Back to lesson: Practice: Clinic Set 1 — Six Classic Bugs