<filename>algoexpert/medium/InvertBinaryTree.py
# O(n) time | o(d) space, n = no of nodes and d = depth of tree
def invertBinaryTree(tree):
    if tree is None:
        return
    tree.left, tree.right = tree.right, tree.left
    invertBinaryTree(tree.left)
    invertBinaryTree(tree.right)

# This is the class of the input binary tree.
class BinaryTree:
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

<filename>algoexpert/medium/InvertBinaryTree.py
# O(n) time | o(d) space, n = no of nodes and d = depth of tree
def invertBinaryTree(tree):
    if tree is None:
        return
    tree.left, tree.right = tree.right, tree.left
    invertBinaryTree(tree.left)
    invertBinaryTree(tree.right)

# This is the class of the input binary tree.
class BinaryTree:
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

# O(n) time | o(d) space, n = no of nodes and d = depth of tree # This is the class of the input binary tree.