Convert BST to Greater Tree

Medium · Binary Search Trees · about 15 minutes

Asked at Amazon, Meta, Google, Microsoft.

The binary search tree has distinct values. Replace each node's value with itself plus the total of every value in the tree that is larger than it, then return the root.

Related guides