VISUALGO//PROBLEMS
maximum depth of binary tree · binary tree – dfseasy
tree
depth
·
max
·
ELEMENTS
root
Python
def maxDepth(root: TreeNode | None) -> int:
if root is None:
return 0
return 1 + max(maxDepth(root.left), maxDepth(root.right))