CodingNodes / Trees System design

Trees

29 animated solutions

Recursion on rooted structures: depth-first traversals, level-order BFS with a queue, and divide-and-conquer over subtrees. Most tree problems ask you to trust the recursion. Every problem below plays as an animated walkthrough with solutions in Python, Java and C++. Companies that ask these most: Wix, Meta, Yahoo.

Average of Levels in Binary Tree
EasyTop Interview 150 ▶ Watch
Balanced Binary Tree
EasyNeetCode 150 ▶ Watch
Convert Sorted Array to Binary Search Tree
EasyTop Interview 150 ▶ Watch
Diameter of Binary Tree
EasyNeetCode 150 ▶ Watch
Invert Binary Tree
EasyNeetCode 150Top Interview 150 ▶ Watch
Maximum Depth of Binary Tree
EasyNeetCode 150Top Interview 150 ▶ Watch
Minimum Absolute Difference in BST
EasyTop Interview 150 ▶ Watch
Path Sum
EasyTop Interview 150 ▶ Watch
Same Tree
EasyNeetCode 150Top Interview 150 ▶ Watch
Subtree of Another Tree
EasyNeetCode 150 ▶ Watch
Symmetric Tree
EasyTop Interview 150 ▶ Watch
Binary Search Tree Iterator
MediumTop Interview 150 ▶ Watch
Binary Tree Level Order Traversal
MediumNeetCode 150Top Interview 150 ▶ Watch
Binary Tree Right Side View
MediumNeetCode 150Top Interview 150 ▶ Watch
Binary Tree Zigzag Level Order Traversal
MediumTop Interview 150 ▶ Watch
Construct Binary Tree From Preorder And Inorder Traversal
MediumNeetCode 150Top Interview 150 ▶ Watch
Construct Binary Tree from Inorder and Postorder Traversal
MediumTop Interview 150 ▶ Watch
Construct Quad Tree
MediumTop Interview 150 ▶ Watch
Count Complete Tree Nodes
MediumTop Interview 150 ▶ Watch
Count Good Nodes In Binary Tree
MediumNeetCode 150 ▶ Watch
Flatten Binary Tree to Linked List
MediumTop Interview 150 ▶ Watch
Kth Smallest Element In a Bst
MediumNeetCode 150Top Interview 150 ▶ Watch
Lowest Common Ancestor of a Binary Search Tree
MediumNeetCode 150 ▶ Watch
Lowest Common Ancestor of a Binary Tree
MediumTop Interview 150 ▶ Watch
Populating Next Right Pointers in Each Node II
MediumTop Interview 150 ▶ Watch
Sum Root to Leaf Numbers
MediumTop Interview 150 ▶ Watch
Validate Binary Search Tree
MediumNeetCode 150Top Interview 150 ▶ Watch
Binary Tree Maximum Path Sum
HardNeetCode 150Top Interview 150 ▶ Watch
Serialize And Deserialize Binary Tree
HardNeetCode 150 ▶ Watch