270. Closest Binary Search Tree Value

iteration, 左右走去找到 upper, lower, 最後比較差值

time: O(h), tree height

space: O(1)

可以參考這個

https://www.jiuzhang.com/problem/closest-binary-search-tree-value/

更精簡的

Last updated

Was this helpful?