"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param root: a TreeNode, the root of the binary tree
@return: nothing
"""
def invertBinaryTree(self, root):
# write your code here
if root is None:
return
root.left,root.right = root.right,root.left
root.left = self.invertBinaryTree(root.left)
root.right = self.invertBinaryTree(root.right)
return root
递归思想,先调换,然后往下继续调换!直到none