669. 修剪二叉搜索树

669. Trim a Binary Search Tree

题目描述

LeetCode

LeetCode669. Trim a Binary Search Tree简单

Java 实现

TreeNode Class

public class TreeNode {
int val;
TreeNode left;
TreeNode right; TreeNode(int x) {
val = x;
}
}
class Solution {
public TreeNode trimBST(TreeNode root, int L, int R) {
if (root == null) {
return null;
}
if (root.val < L) {
return trimBST(root.right, L, R);
}
if (root.val > R) {
return trimBST(root.left, L, R);
}
root.left = trimBST(root.left, L, R);
root.right = trimBST(root.right, L, R);
return root;
}
}

参考资料

最新文章

  1. Exception in thread &quot;main&quot; java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli :
  2. 说一说inline-block的奇葩之处
  3. Windows 服务器开通防火墙后,IISFTP和Serv U开通的FTP账号不能登录
  4. shell脚本修复MySQL主从同步
  5. This application failed to start because it could not find or load the Qt platform plugin &quot;windows&quot;
  6. 2761: [JLOI2011]不重复数字(哈希表)
  7. JavaScript异步加载的三种方式——async和defer、动态创建script
  8. MongoDB + Express 环境搭建记
  9. 分布式任务&amp;分布式锁
  10. android-基础编程-Preference
  11. 转:SQL 关于apply的两种形式cross apply 和 outer apply
  12. 【RF库XML测试】通过xpath查找元素的说明
  13. springboot-5-整合jpa
  14. 创建工具条ToolBar
  15. Java加密代码 转换成Net版
  16. 使用bootstrap时碰到问题$(...).modal is not a function
  17. 搜索二维矩阵 II
  18. Entity Framework查询生成大量的子查询,如何避免?求救
  19. SAN,NAS,DAS的差别
  20. 在有主分支和个人分支情况下的TFS使用方法

热门文章

  1. vs下载代码
  2. 目标检测中的bounding box regression
  3. django-导入应用包的搜索路径
  4. Git学习笔记--配置(二)
  5. Access数据库连接封装类
  6. JavaScript基础03——函数的作用域及变量提升
  7. WinDbg常用命令系列---!htrace
  8. C++函数声明后面加throw()的作用
  9. Codevs 3322 时空跳跃者的困境(组合数 二项式定理)
  10. 《RabbitMQ 实战》读书笔记