dfs
/**
* Definition for a Node.
* type Node struct {
* Val int
* Children []*Node
* }
*/
func maxDepth(root *Node) int {
if root == nil {
return 0
}
maxSubDepth := 0
for _, v := range root.Children {
if v == nil {
continue
}
subDepth := maxDepth(v)
if subDepth > maxSubDepth {
maxSubDepth = subDepth
}
}
return maxSubDepth + 1
}
标签:Node,559,int,maxSubDepth,subDepth,深度,root,leetcode
From: https://www.cnblogs.com/wudanyang/p/17017208.html