diff --git a/590. N-ary Tree Postorder Traversal b/590. N-ary Tree Postorder Traversal new file mode 100644 index 0000000..e6c5029 --- /dev/null +++ b/590. N-ary Tree Postorder Traversal @@ -0,0 +1,22 @@ +class Solution { +public: + vector ans; + + void solve(Node* root) { + if (root == 0) { + return; + } + + for (const auto& node : root->children) { + solve(node); + } + + ans.push_back(root->val); + return; + } + + vector postorder(Node* root) { + solve(root); + return ans; + } +};