Tree

Level: Intermediate

1. Populating Next Right Pointers in Each Node: Connect each node to its next right node in a perfect binary tree.
2. Serialize and Deserialize Binary Tree: Serialize and deserialize a binary tree.
3. Unique Binary Search Trees: Given n, generate all structurally unique BSTs (binary search trees) that store values 1...n.
4. House Robber III: Maximize the amount of money you can rob tonight without alerting the police, based on a binary tree structure of houses.
5. Binary Tree Maximum Width: Find the maximum width of a binary tree.
6. Most Frequent Subtree Sum: Find the most frequent subtree sum in a binary tree.
7. Closest Binary Search Tree Value II: Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target.
8. Path Sum II: Find all paths in a binary tree that sum to a given value.
9. Binary Tree Coloring Game: A two-player game where one player colors a node and its subtree, and the other player colors any other node. Determine if the first player has a winning strategy.
10. All Nodes Distance K in Binary Tree: Find all nodes at distance K from a given target node in a binary tree.
11. Longest Univalue Path: Find the length of the longest path where each node in the path has the same value in a binary tree.
12. Complete Binary Tree Inserter: Insert nodes into a complete binary tree.
13. Lowest Common Ancestor of a Binary Search Tree: Find the lowest common ancestor (LCA) of two nodes in a binary search tree (BST).
14. Binary Tree Vertical Sum: Compute the vertical sum of a binary tree's nodes.
15. Find Duplicate Subtrees: Find all duplicate subtrees in a binary tree.
16. Binary Tree Pruning: Remove nodes from a binary tree that do not contribute to any path sum.
17. Construct Binary Tree from String: Construct a binary tree from a string consisting of preorder and inorder traversals.
18. Binary Tree Diameter: Compute the diameter of a binary tree.
19. Delete Node in a BST: Delete a node in a binary search tree (BST) while maintaining its properties.
20. Distribute Coins in Binary Tree: Distribute coins in such a way that the minimum number of moves are made in a binary tree.
21. Maximum Binary Tree: Construct a maximum binary tree from an array.
22. Binary Tree Longest Consecutive Sequence II: Find the length of the longest consecutive sequence path in a binary tree.
23. Find Largest Value in Each Tree Row: Find the largest value in each row of a binary tree.
24. Second Minimum Node in a Binary Tree: Find the second minimum value in a binary tree.
25. Find Nearest Right Node in Binary Tree: Given the root of a binary tree and a node, find the nearest right node in the same level.
26. Maximum Depth of N-ary Tree: Find the maximum depth of an N-ary tree.
27. N-ary Tree Level Order Traversal: Perform a level order traversal of an N-ary tree.
28. Lowest Common Ancestor of Deepest Leaves: Find the lowest common ancestor of the deepest leaves of a binary tree.
29. Binary Tree Coloring Game: A two-player game where one player colors a node and its subtree, and the other player colors any other node. Determine if the first player has a winning strategy.
30. All Nodes Distance K in Binary Tree: Find all nodes at distance K from a given target node in a binary tree.

Beginner Level: View

Advanced Level: View