375 -二叉树的克隆
来源:互联网 发布:工业大数据 李杰 编辑:程序博客网 时间:2024/05/29 14:34
4.1
没啥感觉,呵呵
就是用递归啊
非递归的懒得写,我真的是懒。
/** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, right; * public TreeNode(int val) { * this.val = val; * this.left = this.right = null; * } * } */public class Solution { /** * @param root: The root of binary tree * @return root of new tree */ public TreeNode cloneTree(TreeNode root) { if(root == null){ return root; } TreeNode newRoot = new TreeNode(root.val); //.val = root.val; newRoot.left = cloneTree(root.left); newRoot.right = cloneTree(root.right); return newRoot; // Write your code here } }
0 0
- 375 -二叉树的克隆
- 二叉树的克隆
- lintcode 375 克隆二叉树
- LintCode:克隆二叉树
- 克隆二叉树
- 克隆二叉树
- lintcode,克隆二叉树
- lintcode | 克隆二叉树
- 克隆二叉树
- 克隆二叉树
- 克隆二叉树
- 克隆二叉树
- LintCode-克隆二叉树
- 克隆二叉树
- 克隆二叉树
- 克隆二叉树
- 克隆二叉树
- LintCode 克隆二叉树
- 非web项目如何配置Druid监控
- PHP导入导出CSV文件
- 剑指offer-面试题23 分层遍历二叉树
- Slf4j使用教程
- angularjs-$interval
- 375 -二叉树的克隆
- 学习计划 -- 实时更新
- ABBYY Recognition Server安装过程中出现错误代码1935
- jsp页面用el表达式取属性值的原理${bean.field}
- 剑指offer-面试题24 二叉搜索树的后序遍历序列
- 02 List、Tuple、Dict、Set
- scp跨服务器拷贝,后台运行
- 51和AVR单片机
- linux下生成动态链接库并使用(使用cmake)