0590. Postorder Traversal
Easy | Tree + Recursion / Stack | 32 ms (98.77%), 16.3 MB (94.57%)
Last updated
Was this helpful?
Easy | Tree + Recursion / Stack | 32 ms (98.77%), 16.3 MB (94.57%)
Last updated
Was this helpful?
Source: GitHub:
Given the root
of an n-ary tree, return the postorder traversal of its nodes' values.
Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples)
Follow up: Recursive solution is trivial, could you do it iteratively?
Excepting the above hints, we visit the child nodes first before appending each node's value.