N-ary Tree Postorder Traversal LeetCode solution in C++
1class Solution {2public:3void solve(Node *root, vector<int> &ans) {4if (root == NULL) return;5for (int i = 0; i < root->children.size(); i++) {6solve(root->children[i], ans);7}8ans.push_back(root->val);9}10vector<int> postorder(Node *root) {11vector<int> ans;12solve(root, ans);13return ans;14}