标签:code tree auto cto ret solution tor leetcode roo
树的后序遍历。
class Solution { public: vector<Node> Tree; void postTree(Node node) { for (auto n : node.children) { Node node; node = Node(n->val, n->children); postTree(node); } Tree.push_back(Node(node.val, node.children)); } vector<int> postorder(Node* root) { vector<int> V; if (root != NULL) { postTree(*root); } for (auto n : Tree) { V.push_back(n.val); } return V; } };
标签:code tree auto cto ret solution tor leetcode roo
原文地址:https://www.cnblogs.com/asenyang/p/9704415.html