Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all of its elements lie within the inclusive range low$,
Trimming the tree should preserve the relative structure of the remaining nodes, such that any node that was a descendant of another node remains a descendant. Return the root of the trimmed binary search tree.
Note: The root of the tree may change depending on the given bounds.
Constraints:
The number of nodes in the tree is in the range
Node.val
The value of each node in the tree is unique.
root is guaranteed to be a valid binary search tree.
low high
Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all of its elements lie within the inclusive range low$,
Trimming the tree should preserve the relative structure of the remaining nodes, such that any node that was a descendant of another node remains a descendant. Return the root of the trimmed binary search tree.
Note: The root of the tree may change depending on the given bounds.
Constraints:
The number of nodes in the tree is in the range
Node.val
The value of each node in the tree is unique.
root is guaranteed to be a valid binary search tree.
low high