Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the result should return the new root of the trimmed binary search tree.
Example
No.1
Input:
1 | 1 |
Output:
1 | 1 |
No.2
Input:
1 | 3 |
Output:
1 | 3 |
Code
1 | public class TreeNode { |
1 | public TreeNode trimBST(TreeNode root, int L, int R) { |