awesome-everything RU
↑ Back to the climb

Algorithms from zero

Trees: interview drill

Crux Timed tree and trie problems from the NeetCode-150, with progressive hints — solve each cold, then narrate the complexity.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 120 min

You understand trees and tries. Interviews test whether you can reach for them under a timer, cold, and explain the cost out loud.

Goal

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

#226 Invert Binary TreeEasy10m
AmazonGoogle
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.

#104 Maximum Depth of Binary TreeEasy10m
Amazon
Follow-up (aloud)

Give an iterative version with a stack or BFS queue, and say which one naturally measures depth level by level.

#100 Same TreeEasy10m
Amazon
Follow-up (aloud)

How does this routine become the helper for checking whether one tree is a subtree of another?

#102 Binary Tree Level Order TraversalMedium15m
AmazonMicrosoft
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?

#98 Validate Binary Search TreeMedium20m
AmazonMeta
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

#208 Implement Trie (Prefix Tree)Medium20m
AmazonGoogle
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.

Recap

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.

Continue the climb ↑The heap
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources2
expand
  1. 01
  2. 02

Trademarks belong to their respective owners. Editorial reference only.