Solved LeetCode program · 940 of 1,000
#1305 · All Elements in Two Binary Search Trees
Original English source
Keep a shared firstvalues holding 2, 1, and 4. Keep a shared firstlefts holding 1, -1, and -1. Keep a shared firstrights holding 2, -1, and -1. Keep a shared secondvalues holding 1, 0, and 3. Keep a shared secondlefts holding 1, -1, and -1. Keep a shared secondrights holding 2, -1, and -1. Keep a shared combined as an empty list of whole numbers.
To gather first from node (a whole number). If node is less than 0, return. Gather first from item node of firstlefts. Place item node of firstvalues into combined. Gather first from item node of firstrights.
To gather second from node (a whole number). If node is less than 0, return. Gather second from item node of secondlefts. Place item node of secondvalues into combined. Gather second from item node of secondrights.
Gather first from 0. Gather second from 0. Sort combined. The pieces is an empty list of text.
For each value in combined.
The piece is format whole number value as text. Place piece into pieces.
The line is join pieces with ",". Show line.
Expected stdout
0,1,1,2,3,4