leetcode-590. N 叉树的后序遍历
可以参考 [[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
}
本文来自博客园,作者:吴丹阳-V,转载请注明原文链接:https://www.cnblogs.com/wudanyang/p/17017961.html

                
            
        
浙公网安备 33010602011771号