Solved LeetCode program · 98 of 1,000
#0098 · Validate Binary Search Tree
Original English source
Keep a shared values holding 2, 1, and 3. Keep a shared lefts holding 1, -1, and -1. Keep a shared rights holding 2, -1, and -1. Keep a shared order as an empty list of whole numbers. Keep a shared order count as 0.
To gather from node (a whole number). If node is less than 0, return. Gather from item node of lefts. Place node into order. Add 1 to order count. Gather from item node of rights.
Gather from 0. The valid is 1. The last is order count minus 1.
For every position from 1 to last.
The before is item (position minus 1) of order. The current is item position of order. If item before of values is at least item current of values, set valid to 0.
If valid is 1, report true. Otherwise, report false.
Expected stdout
true