18 求最大树深

优质
小牛编辑
128浏览
2023-12-01
def maxDepth(root):
    if not root:
      return 0
    return max(maxDepth(root.left), maxDepth(root.right)) + 1