The Convert BST to Greater Tree interview question asks you to modify a BST such that every node's value is replaced by its original value plus the sum of all values strictly greater than it in the original BST.
This Convert BST to Greater Tree coding problem is common at Microsoft and Amazon. It tests whether a candidate can modify standard traversal algorithms to fit specific constraints. It specifically checks if you realize that a "Reverse In-order Traversal" (Right, Root, Left) visits nodes in descending order, making it easy to maintain a running sum.
This follows the Binary Search Tree, Depth-First Search interview pattern.
BST:
4
/
1 6
10
/
11 6
Whenever a BST problem involves "greater than" or "smaller than" relationships, think about which direction of in-order traversal (ascending or descending) will let you process the data in the right order.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Inorder Successor in BST | Medium | Solve | |
| Recover Binary Search Tree | Medium | Solve | |
| Binary Search Tree to Greater Sum Tree | Medium | Solve | |
| Kth Smallest Element in a BST | Medium | Solve | |
| Lowest Common Ancestor of a Binary Search Tree | Medium | Solve |