The TransCompilator

Solved LeetCode program · 429 of 1,000

#0590 · N-ary Tree Postorder Traversal

Easy Depth-First Search chunk-09.md

Original English source

Keep a shared values holding 1, 3, 2, 4, 5, and 6. Keep a shared firstchild holding 1, 4, -1, -1, -1, and -1. Keep a shared nextsibling holding -1, 2, 3, -1, 5, and -1. Keep a shared order as an empty list of whole numbers.

To gather from node (a whole number). If node is less than 0, return. Visit from item node of firstchild with node.

To visit from child (a whole number) with parent (a whole number). If child is less than 0, Place item parent of values into order, return. Gather from child. Visit from item child of nextsibling with parent.

Gather from 0. For each value in order, show value.

Open in Playground Browse all 1,000 problems

Expected stdout

5
6
3
2
4
1