LC: 270. Closest Binary Search Tree Value - spiralgo/algorithms GitHub Wiki
270. Closest Binary Search Tree Value:
The Essence:
As it is a Binary Search Tree, a binary search algorithm will be the perfect match.
Details:
We should find the difference between the target node and the value first.
If the target is greater than the value, we should search on the left side of the tree. Otherwise, we should try the right side.
In each iteration we should update the closest variable using Math.min() method, as it might have been found in any iteration.