python in o(n)


  • 0
    L

    class Solution(object):
    def invertTree(self, root):
    """
    :type root: TreeNode
    :rtype: TreeNode
    """
    if not root:
    return None
    root.left,root.right=root.right,root.left
    self.invertTree(root.left)
    self.invertTree(root.right)
    return root


Log in to reply
 

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