Trees
Process a tree by solving each subtree and combining the results, using recursion for depth or a queue for levels. The tell is any hierarchy of nodes, as in Maximum Depth of Binary Tree and Binary Tree Level Order Traversal. Most answers come from one visit per node.
38 problems · 19 with a video · 3 to practice in an AI round
| # | Problem | Difficulty | Video | AI round |
|---|---|---|---|---|
| 1 | Lowest Common Ancestor of a Binary Tree | Medium | — | AI round |
| 2 | Validate Binary Search Tree | Medium | AI round | |
| 3 | Binary Tree Level Order Traversal | Medium | AI round | |
| 4 | Symmetric Tree | Easy | ||
| 5 | Construct Binary Tree from Preorder and Inorder Traversal | Medium | ||
| 6 | Diameter of Binary Tree | Easy | ||
| 7 | Invert Binary Tree | Easy | ||
| 8 | Binary Tree Inorder Traversal | Easy | ||
| 9 | Maximum Depth of Binary Tree | Easy | ||
| 10 | Binary Tree Right Side View | Medium | ||
| 11 | Same Tree | Easy | ||
| 12 | Kth Smallest Element in a BST | Medium | — | |
| 13 | Lowest Common Ancestor of a Binary Search Tree | Medium | — | |
| 14 | Balanced Binary Tree | Easy | — | |
| 15 | All Nodes Distance K in Binary Tree | Medium | — | |
| 16 | Binary Tree Zigzag Level Order Traversal | Medium | ||
| 17 | Convert Sorted Array to Binary Search Tree | Easy | — | |
| 18 | Path Sum III | Medium | — | |
| 19 | Path Sum | Easy | ||
| 20 | Delete Node in a BST | Medium | — | |
| 21 | Maximum Width of Binary Tree | Medium | — | |
| 22 | Count Complete Tree Nodes | Medium | ||
| 23 | Subtree of Another Tree | Easy | ||
| 24 | Binary Tree Preorder Traversal | Easy | ||
| 25 | Recover Binary Search Tree | Medium | — | |
| 26 | Minimum Depth of Binary Tree | Easy | ||
| 27 | Binary Tree Postorder Traversal | Easy | ||
| 28 | Range Sum of BST | Very easy | ||
| 29 | Average of Levels in Binary Tree | Easy | ||
| 30 | Binary Tree Vertical Order Traversal | Medium | — | |
| 31 | Find Leaves of Binary Tree | Medium | — | |
| 32 | Inorder Successor in BST | Medium | — | |
| 33 | Count Univalue Subtrees | Medium | — | |
| 34 | Binary Tree Longest Consecutive Sequence II | Medium | — | |
| 35 | Binary Tree Longest Consecutive Sequence | Medium | — | |
| 36 | Kill Process | Medium | — | |
| 37 | Construct Binary Tree from String | Medium | — | |
| 38 | Serialize and Deserialize N-ary Tree | Hard | — |
Sort by what interviews ask
Sign in to see how many companies ask each problem, sort all 500 by it or by likes, and tick off what you solve.
Practice in an AI round
Three of these are AI rounds: 30 minutes, an AI agent beside your code, then a scored report.
Practice Lowest Common Ancestor of a Binary Tree in an AI roundYour first AI round is free.