递归,每次向上传递层数时 +1 package main import . "nc_tools" func maxDepth(root *TreeNode) (deep int) { if root != nil { left := maxDepth(root.Left) right := maxDepth(root.Right) if left > right { deep = left + 1 } else { deep = right + 1 } } return }
点赞

相关推荐

xtu大迫杰:偶遇校友,祝校友offer打牌
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务