Cutting Binary Search Tree
Given a binary search tree root
, an integer lo
, and another an integer hi
, remove all nodes that are not between [lo, hi]
inclusive.
Constraints
n ≤ 100,000
wheren
is the number of nodes inroot
https://binarysearch.com/problems/Cutting-Binary-Search-Tree
Examples
Example 1
Input
- root =
- lo =
3
- hi =
4
Output
- answer =
Example 2
Input
- root =
- lo =
7
- hi =
10
Output
- answer =
Leave a comment