/**
* Definition for a Node.
* type Node struct {
* Val int
* Children []*Node
* }
*/
func maxDepth(root *Node) int {
if root == nil {
return 0
} else if len(root.Children) == 0 {
return 1
} else {
var heights []int
for _, node := range root.Children {
heights = append(heights, maxDepth(node)+1)
}
return max(heights)
}
}
func max(arr []int) int {
m := 0
for _, a := range arr {
if a > m {
m = a
}
}
return m
}