Algorithms from zero
Graphs: interview drill
You understand DFS, BFS, and shortest paths. Interviews test whether you can recognise a grid or a prerequisite list as a graph in disguise, pick the right traversal under a timer, and explain the cost out loud.
Solve each problem before you reveal a hint, hit the target time, and narrate the time and space complexity as if an interviewer were listening. The hints exist for when you are genuinely stuck — they nudge you toward the pattern, never the full solution.
Five NeetCode-150 problems on the graph traversal and advanced-graph patterns this unit teaches. Set a timer, solve each cold without looking at a hint, then say the time and space complexity out loud before you move on. Reveal a hint only when you are truly stuck — the hints nudge, they never hand you the answer.
0/5 solved
graphs
Follow-up (aloud)
State the time complexity in terms of rows and columns. Why is each cell touched a constant number of times despite the nested traversal?
Follow-up (aloud)
Why does the visited map serve double duty as both the cycle guard and the result? What is the space complexity?
Follow-up (aloud)
Contrast DFS cycle detection with Kahn's algorithm: what state does each track, and how does each conclude a cycle exists?
Follow-up (aloud)
Why is flooding inward from the oceans asymptotically cheaper than flooding outward from every cell? Give both complexities.
advanced graphs
Follow-up (aloud)
State Dijkstra's complexity with a binary heap. Why does it require non-negative edge weights, and what would you reach for if some were negative?
Mark each problem solved once you finished it cold, inside the target time, and could state the complexity without hesitation. Come back in a few days and re-solve the ones you marked — spaced revisits are what turn a recognised pattern into a reflex.