Files
Hot-100-Algorithm/二叉树/二叉树的最大深度/main.go

20 lines
258 B
Go
Raw Normal View History

2025-08-26 06:18:10 +08:00
package main
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func main() {}
func maxDepth(root *TreeNode) int {
if root == nil {
return 0
}
maxnum := 1
maxnum += max(maxDepth(root.Left), maxDepth(root.Right))
return maxnum
}