Solved LeetCode program · 396 of 1,000
#0530 · Minimum Absolute Difference in BST
Original English source
Keep a shared values holding 4, 2, 6, 1, and 3. Keep a shared lefts holding 1, 3, -1, -1, and -1. Keep a shared rights holding 2, 4, -1, -1, and -1. Keep a shared previous of 0. Keep a shared started of 0. Keep a shared closest of 1000000.
To walk from node (a whole number). If node is less than 0, return. Walk from item node of lefts. The here is item node of values. The gap is here minus previous. If started is 1 and gap is less than closest, set closest to gap. Set previous to here. Set started to 1. Walk from item node of rights.
Walk from 0. Show closest.
Expected stdout
1