Trees coding problems
Tree problems build recursion and traversal skills: depth, diameter, paths, lowest common ancestor and level-order views, all common in product-company interviews.
20 problems: 11 easy, 9 medium, 0 hard. Free to read; a free account solves them and earns XP and Aura.
- Count Nodes at Depth KPractice · +10 XP · trees, bfs, dfseasy
- Count Nodes Greater Than ParentPractice · +10 XP · trees, parent arrayeasy
- Count Tree EdgesPractice · +10 XP · graphs, trees, bfseasy
- Find Root of TreePractice · +10 XP · trees, arrayseasy
- Leaf CountPractice · +10 XP · trees, arrayseasy
- Parent Array RootPractice · +10 XP · trees, arrayseasy
- Print Tree LevelsPractice · +10 XP · trees, traversals, bfseasy
- Root to Leaf Path SumPractice · +10 XP · trees, traversals, recursioneasy
- Sum of Subtree SizesPractice · +10 XP · trees, dfs, recursioneasy
- Tree Depth SumPractice · +10 XP · trees, arrays, summationeasy
- Tree Path SumPractice · +10 XP · trees, trees/traversals, trees/parent_arrayeasy
- Find Bridges in a TreePractice · +20 XP · graphs, dfs, treesmedium
- Find Longest Path to LeafPractice · +20 XP · trees, dfsmedium
- Find Minimum Depth Binary TreePractice · +20 XP · recursion, trees, bfsmedium
- Maximum Depth Path SumPractice · +20 XP · trees, dynamic programming, depth first searchmedium
- Maximum Depth Sum of Unique PathsPractice · +20 XP · trees, bfs, prefix summedium
- Tree Ancestor SumPractice · +20 XP · trees, prefix sums, traversalsmedium
- Tree Diameter and CenterPractice · +20 XP · trees, bfsmedium
- Tree Path CountPractice · +20 XP · trees, dfsmedium
- Tree Subtree SumsPractice · +20 XP · trees, dfs, hash mapmedium
Solve these free. Get paid in XP and Aura.
One tap with Google, no card. Every first accepted solve pays XP for the leaderboards and Aura for real goodies.
Other topics
Hash Map and Hashing101Arrays88Prefix Sums64SQL and Databases64Beginner Coding Problems60Graphs, BFS and DFS45Greedy41Sliding Window39Dynamic Programming37Sorting36Math and Number Theory36Strings35Two Pointers35Stack29Binary Search25Simulation25Recursion22Linked List20Heap and Priority Queue18Matrix and Grid18Bit Manipulation18Queue and Deque16