30:00
Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree.
The number of nodes in the tree is in the range [2,104][2, 10^4][2,104].
0≤Node.val≤1050 \leq \text{Node.val} \leq 10^50≤Node.val≤105
Run code to see results.
prev starts empty and best at infinity. An inorder walk of a BST meets the values in sorted order, so only neighbours in that order need comparing.
open calls
none
prev = None best = inf
Given a binary search tree, find the smallest difference between the values of any two nodes. The tree has at least two nodes and every value is between 0 and 100,000.