这个思路还是 递归的,下面是迭代的提升:
思路: 迭代进行了 NRL 的先序 迭代 遍历,然后reverse NRL 到 LRN 就是 要求的后序遍历了啊。ok
https://leetcode-cn.com/problems/n-ary-tree-preorder-traversal
位置在前面,因为是先序(对比上面的后序遍历, 你可以看到后序遍历的 ans.add(root.val)
在后面。
原文:https://www.cnblogs.com/paulkg12/p/12262988.html