less than 1 minute read

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 where n is the number of nodes in root

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 =

Solution

Leave a comment