Solved LeetCode program · 296 of 1,000
#0404 · Sum of Left Leaves
Original English source
Keep a shared values holding 3, 9, 20, 0, 0, 15, and 7. Keep a shared lefts holding 1, -1, 5, -1, -1, -1, and -1. Keep a shared rights holding 2, -1, 6, -1, -1, -1, and -1.
Keep a shared total of 0.
To visit from node (a whole number) with side (a whole number). If node is less than 0, return. The leftnode is item node of lefts. The rightnode is item node of rights. The amount is item node of values. If leftnode is -1 and rightnode is -1 and side is 1, add amount to total. Visit from leftnode with 1. Visit from rightnode with 0.
Visit from 0 with 0. Show total.
Expected stdout
24