LeetCode题解之N-ary Tree Postorder Traversal

1、题目描述

2、问题分析

递归。

3、代码

 1 vector<int> postorder(Node* root) {
 2         vector<int> v;
 3         postNorder(root, v);
 4         return v;
 5     }
 6     
 7     void postNorder(Node *root, vector<int> &v)
 8     {
 9         if (root == NULL)
10             return;
11         for (auto it = root->children.begin(); it != root->children.end(); it++) {
12             postNorder(*it, v);
13         }
14         
15         v.push_back(root->val);
16     }
原文地址:https://www.cnblogs.com/wangxiaoyong/p/10424473.html