Algorithms from zero
Trees: interview drill
You understand trees and tries. 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.
Six NeetCode-150 problems on the trees and tries 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/6 solved
trees
Follow-up (aloud)
State the O(n) time, then explain why the space is O(h) and what h equals for a balanced versus a degenerate tree.
Follow-up (aloud)
Give an iterative version with a stack or BFS queue, and say which one naturally measures depth level by level.
Follow-up (aloud)
How does this routine become the helper for checking whether one tree is a subtree of another?
Follow-up (aloud)
Why is snapshotting the queue size per level the crux, and what is the worst-case space in terms of the widest level?
Follow-up (aloud)
Contrast the bounds approach with the in-order approach on correctness and space, and name an input that breaks the naive parent-only check.
tries
Follow-up (aloud)
Give the time for each operation in terms of word length L, and explain why a trie can beat a hash set for prefix queries.
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.