添加新题目
This commit is contained in:
19
二叉树/二叉树的最大深度/main.go
Normal file
19
二叉树/二叉树的最大深度/main.go
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user