Trees • Beginner • 10 min
Invert Binary Tree
How to notice that inverting a tree is just swapping left and right at each node and letting recursion handle the rest.
Practice problems with walkthroughs, hints, and solutions.
Filter by type or level
Trees • Beginner • 10 min
How to notice that inverting a tree is just swapping left and right at each node and letting recursion handle the rest.
Trees • Beginner • 10 min
How to measure tree height by thinking about leaves, subtrees, and the combination `1 + max(left, right)`.
Trees • Intermediate • 20 min
How to validate a BST by propagating limits through recursion instead of doing local comparisons that look right but break.
Trees • Intermediate • 18 min
How to traverse a tree level by level with a queue and clearly separate what belongs to the current level before moving down.
Trees • Advanced • 30 min
How to turn a tree into a string and back while preserving the null markers that define its shape.
Trees • Intermediate • 18 min
How to search for a real subtree by comparing shape and values, not just roots that seem to match.
Trees • Intermediate • 15 min
How to use inorder traversal to exploit the BST ordering and stop as soon as the counter reaches k.