Solved LeetCode program · 703 of 1,000
#0938 · Range Sum of BST
Original English source
Keep a shared values holding 10, 5, 15, 3, 7, -1, and 18. Keep a shared lefts holding 1, 3, 5, -1, -1, -1, and -1. Keep a shared rights holding 2, 4, 6, -1, -1, -1, and -1. Keep a shared low of 0. Keep a shared high of 0. Keep a shared total of 0. Set low to 7. Set high to 15.
To gather from node (a whole number). If node is less than 0, return. The value is item node of values. If value is at least low and value is at most high, add value to total. If value is more than low, Gather from item node of lefts. If value is less than high, Gather from item node of rights.
Gather from 0. Show total.
Expected stdout
32