Easy Understanding Python Solution


  • 0
    A
    def invertTree(self, root):
            """
            :type root: TreeNode
            :rtype: TreeNode
            """
            if root == None:
                return None
            else:
                temp = TreeNode(root.val)
                x = temp.val
                temp.left = self.invertTree(root.right)
                temp.right = self.invertTree(root.left)
                return temp
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.