590. N-ary Tree Postorder Traversal

https://leetcode.com/problems/n-ary-tree-postorder-traversal/

preorder: root left right

so postorder: left right root

=> root right left

=> reverse ( use linkedList addFirst(), 注意要用這個要頭尾都宣告LinkedList<> list = new LinkedList<>() 才會有這個方法

=>得到答案

O(M), O(M) M is the total nodes of this tree

recursive

Last updated

Was this helpful?