226. 翻转二叉树
作者:互联网
"""
226. 翻转二叉树
翻转一棵二叉树。
示例:
输入:
4
/ \
2 7
/ \ / \
1 3 6 9
输出:
4
/ \
7 2
/ \ / \
9 6 3 1
"""
class Solution(object):
def invertTree(self, root):
if root is None:
return
tmp = root.left
root.left = root.right
root.right = tmp
self.invertTree(root.left)
self.invertTree(root.right)
return root
标签:right,invertTree,self,二叉树,226,left,root,翻转 来源: https://www.cnblogs.com/tomorrow-hope/p/15681822.html