Given the root of a Binary Search Tree (BST), convert it into a Greater Tree such that each node’s value is replaced with the sum of its original value and the values of all nodes in the tree that are greater than it.
Return the root of the modified tree.
Constraints:
The number of nodes in the tree is in the range
Node.val
All the values in the tree are unique.
root is guaranteed to be a valid binary search tree.
Given the root of a Binary Search Tree (BST), convert it into a Greater Tree such that each node’s value is replaced with the sum of its original value and the values of all nodes in the tree that are greater than it.
Return the root of the modified tree.
Constraints:
The number of nodes in the tree is in the range
Node.val
All the values in the tree are unique.
root is guaranteed to be a valid binary search tree.