leetcode - 226 - 翻转二叉树
2018-10-31 09:53
246 查看
阅读更多# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = Noneclass Solution:
def invertTree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
if root is None:
return root
temp = root.left
root.left = root.right
root.right = tempself.invertTree(root.left) #递归
self.invertTree(root.right)
return root
相关文章推荐
- [LeetCode] 226 翻转二叉树
- leetcode 226 Invert Binary Tree 翻转二叉树
- leetcode 226 Invert Binary Tree 翻转二叉树
- 翻转二叉树(leetcode-226)
- leetcode 226 Invert Binary Tree 翻转二叉树
- 【LeetCode】226. Invert Binary Tree 二叉树翻转
- LeetCode 226 Invert Binary Tree(翻转二叉树)
- leetcode 226. Invert Binary Tree(C语言,二叉树,递归)54
- LeetCode 226. Invert Binary Tree(反转二叉树)
- ※ Leetcode - Tree - 226. Invert Binary Tree(反转二叉树 使用二级指针交换两个指针的地址)
- [LeetCode] Invert Binary Tree 翻转二叉树
- LeetCode226:Invert Binary Tree 二叉树反转
- LeetCode 226 Invert Binary Tree(转换二叉树)
- Leetcode 226 Invert Binary Tree 反转二叉树
- 【LeetCode】Invert Binary Tree 翻转二叉树 - Easy++
- LeetCode Invert Binary Tree 翻转二叉树
- leetCode之翻转二叉树
- Leetcode 226: Invert Binary Tree(二叉树反转 递归、非递归实现)
- 【LeetCode-面试算法经典-Java实现】【226-Invert Binary Tree(反转二叉树)】