Solved LeetCode program · 557 of 1,000
#0783 · Minimum Distance Between BST Nodes
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 -1. Keep a shared best of 1000000.
To gather from node (a whole number). If node is less than 0, return. Gather from item node of lefts. The here is item node of values. If previous is at least 0 and here minus previous is less than best, set best to here minus previous. Set previous to here. Gather from item node of rights.
Gather from 0. Show best.
Expected stdout
1