669. Trim a Binary Search Tree
题目描述
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.
|
|
|
|
题目大意
保留二叉树内值为[L, R]之间的节点
解题思路
递归
寻找值在[L, R]之间的节点,修建其左右子树
代码
|
|