Algorithms from zero
Lists, stacks & queues: interview drill
You understand linked lists and stacks. Interviews test whether you can reach for them under a timer, cold, 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.
Seven NeetCode-150 problems on the linked-list and stack 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/7 solved
linked list
Follow-up (aloud)
This is O(n) time, O(1) space iteratively. Sketch the recursive version and explain why its space becomes O(n).
Follow-up (aloud)
Why is splicing existing nodes O(1) extra space, and how is this the merge step that powers merge sort on lists?
Follow-up (aloud)
Argue why the fast pointer is guaranteed to lap the slow one inside a cycle, and why they never meet when the list is acyclic.
Follow-up (aloud)
Walk the interviewer through how you keep this O(1) extra space, and where an off-by-one in the split would corrupt the result.
stack
Follow-up (aloud)
Name the two failure cases the empty-stack check at the end catches versus the mismatch check catches mid-scan.
Follow-up (aloud)
All four operations must be O(1). Explain why the auxiliary-stack trick beats scanning for the min on every getMin.
Follow-up (aloud)
Defend the O(n) bound via amortized analysis, and name another problem the same monotonic-stack idea solves.
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.