669. 修剪二叉搜索树
https://leetcode-cn.com/problems/trim-a-binary-search-tree/
解法一:
1.若root的val < L,则其左子树必小于L,因此root和其左子树不用再管,处理右子树.
2.若root的val > R,思路类比于2.
3.如果root在[L,R]范围内,返回root,并处理它的左子树和右子树.
最后更新于
https://leetcode-cn.com/problems/trim-a-binary-search-tree/
1.若root的val < L,则其左子树必小于L,因此root和其左子树不用再管,处理右子树.
2.若root的val > R,思路类比于2.
3.如果root在[L,R]范围内,返回root,并处理它的左子树和右子树.
最后更新于