The TransCompilator

Solved LeetCode program · 557 of 1,000

#0783 · Minimum Distance Between BST Nodes

Easy Depth-First Search chunk-12.md

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.

Open in Playground Browse all 1,000 problems

Expected stdout

1