226. Invert Binary Tree
题目:
https://leetcode.com/problems/invert-binary-tree/
难度:
Easy
class Solution(object):
def invertTree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
if root == None: return None
elif root.left == None and root.right == None: return root
else:
leftNode = root.left
rightNode = root.right
root.right = leftNode
root.left = rightNode
self.invertTree(root.left)
self.invertTree(root.right)
return root