【leetcode❤python】226. Invert Binary Tree

#-*- coding: UTF-8 -*-
# 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):
        if root==None:return None
        tempRoot=root.left
        root.left=root.right
        root.right=tempRoot
        
        self.invertTree(root.right)
        self.invertTree(root.left)
        
        return root

上一篇:LeftoverDataException,依赖包,apache license 2.0


下一篇:Activiti 学习笔记记录(二)