/*
// Definition for a Node.
class Node {
public:
int val;
vector<Node*> children;
Node() {}
Node(int _val, vector<Node*> _children) {
val = _val;
children = _children;
}
};
*/
class Solution {
public:
int post(Node* root, vector<int>& res){
if(root == nullptr){
return 0;
}
for(auto child:root->children){
post(child, res);
}
res.push_back(root->val);
return 0;
}
vector<int> postorder(Node* root) {
vector<int> res;
if(root == nullptr){
return res;
}
post(root, res);
return res;
}
};