可以参考 [[leetcode-589. N 叉树的前序遍历]] ,代码差不多
/**
* Definition for a Node.
* type Node struct {
* Val int
* Children []*Node
* }
*/
func postorder(root *Node) []int {
if root == nil {
return []int{}
}
curSeq := []int{}
for _, v := range root.Children {
if v != nil {
subSeq := postorder(v)
curSeq = append(curSeq, subSeq...)
}
}
curSeq = append(curSeq, root.Val)
return curSeq
}
标签:Node,590,遍历,curSeq,int,root,leetcode
From: https://www.cnblogs.com/wudanyang/p/17017961.html