# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None class Solution(object):
def invertTree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
if root is None:
return None
if root.left:
self.invertTree(root.left)
if root.right:
self.invertTree(root.right)
root.left,root.right=root.right,root.left
return root
相关文章
- 12-0530 Day Challenge Day 7 | Leetcode 235. Lowest Common Ancestor of a Binary Search Tree
- 12-05Python3解leetcode Lowest Common Ancestor of a Binary Search TreeBinary Tree Paths
- 12-05LeetCode-236 Lowest Common Ancestor of a Binary Tree
- 12-05LeetCode236. Lowest Common Ancestor of a Binary Tree(二叉树的最近公共祖先)
- 12-05Leetcode606.Construct String from Binary Tree根据二叉树创建字符串
- 12-05【Leetcode_easy】606. Construct String from Binary Tree
- 12-05LeetCode 606 Construct String from Binary Tree 解题报告
- 12-05【LeetCode】606. Construct String from Binary Tree 解题报告(Python)
- 12-05leetcode题解:Binary Tree Postorder Traversal (二叉树的后序遍历)
- 12-05LeetCode 145. Binary Tree Postorder Traversal二叉树的后序遍历 (C++)