LintCode:克隆二叉树
来源:互联网 发布:淘宝限购在哪里设置 编辑:程序博客网 时间:2024/05/01 22:43
LintCode:克隆二叉树
"""Definition of TreeNode:class TreeNode: def __init__(self, val): this.val = val this.left, this.right = None, None"""class Solution: """ @param {TreeNode} root: The root of binary tree @return {TreeNode} root of new tree """ def cloneTree(self, root): # Write your code here if not root: return root my_root = TreeNode(root.val) self.pre_order_clone(my_root, root) return my_root def pre_order_clone(self, my_root, root): if not root: return if root.left: my_root.left = TreeNode(root.left.val) self.pre_order_clone(my_root.left, root.left) if root.right: my_root.right = TreeNode(root.right.val) self.pre_order_clone(my_root.right, root.right)
0 0
- LintCode:克隆二叉树
- lintcode,克隆二叉树
- lintcode | 克隆二叉树
- LintCode-克隆二叉树
- LintCode 克隆二叉树
- 克隆二叉树-LintCode
- Lintcode 克隆二叉树
- LintCode 克隆二叉树
- lintcode -- 克隆二叉树
- lintcode:克隆二叉树
- 克隆二叉树-LintCode
- lintcode 375 克隆二叉树
- [LintCode]375.克隆二叉树
- lintcode——克隆二叉树
- LintCode算法题解——判断数独是否合法、平面列表、克隆二叉树、序列排号
- 二叉树的克隆
- 克隆二叉树
- 克隆二叉树
- poj 2559 Largest Rectangle in a Histogram 求面积最大的矩形(单调栈)
- PING++微信支付问题小结
- Ubuntu,kubuntu与xubuntu的差别 Ubuntu各版本主要差异
- MySQL隐式转化整理
- idea 14提示override错误
- LintCode:克隆二叉树
- Java的初始化顺序
- 坚持#第25天~aditplus更熟悉了
- JVM GC中Stop the world案例实战
- 手动把web项目部署到tomcat
- POJ 1101 解题报告
- 《七周七Web开发框架》读后感
- 跨站点请求伪造
- Struts2工具类[实现获取Request/Response/Session与绕过jsp/freemaker直接输出文本的简化函数]