from Tree import ConstructBinaryTreeFromPreorderAndInorderTraversal
preorder = [3, 9, 20, 15, 7]
inorder = [9, 3, 15, 20, 7]
a = ConstructBinaryTreeFromPreorderAndInorderTraversal.Solution().buildTree(
    preorder, inorder)


def maxDepth(root):
    if not root:
        return 0
    else:
        maxLeftDepth = maxDepth(root.left)
        maxRightDepth = maxDepth(root.right)
        return max(maxLeftDepth, maxRightDepth) + 1


print(maxDepth(a))

d22ff904b5e457199ea6b04f8b7fa6788269d3aa
<mask token>


def maxDepth(root):
    if not root:
        return 0
    else:
        maxLeftDepth = maxDepth(root.left)
        maxRightDepth = maxDepth(root.right)
        return max(maxLeftDepth, maxRightDepth) + 1


<mask token>

<mask token>


def maxDepth(root):
    if not root:
        return 0
    else:
        maxLeftDepth = maxDepth(root.left)
        maxRightDepth = maxDepth(root.right)
        return max(maxLeftDepth, maxRightDepth) + 1


print(maxDepth(a))

<mask token>
preorder = [3, 9, 20, 15, 7]
inorder = [9, 3, 15, 20, 7]
a = ConstructBinaryTreeFromPreorderAndInorderTraversal.Solution().buildTree(
    preorder, inorder)


def maxDepth(root):
    if not root:
        return 0
    else:
        maxLeftDepth = maxDepth(root.left)
        maxRightDepth = maxDepth(root.right)
        return max(maxLeftDepth, maxRightDepth) + 1


print(maxDepth(a))

from Tree import ConstructBinaryTreeFromPreorderAndInorderTraversal
preorder = [3, 9, 20, 15, 7]
inorder = [9, 3, 15, 20, 7]
a = ConstructBinaryTreeFromPreorderAndInorderTraversal.Solution().buildTree(
    preorder, inorder)


def maxDepth(root):
    if not root:
        return 0
    else:
        maxLeftDepth = maxDepth(root.left)
        maxRightDepth = maxDepth(root.right)
        return max(maxLeftDepth, maxRightDepth) + 1


print(maxDepth(a))
