The TransCompilator

Solved LeetCode program · 144 of 1,000

#0144 · Binary Tree Preorder Traversal

Easy Depth-First Search chunk-03.md

Original English source

Keep a shared values holding 1, 2, and 3. Keep a shared lefts holding -1, -1, and -1. Keep a shared rights holding 1, 2, 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. Place node into order. Gather from item node of lefts. Gather from item node of rights.

Gather from 0. For each node in order, show item node of values.

Open in Playground Browse all 1,000 problems

Expected stdout

1
2
3