270 Closest Binary Search Tree Value
270. Closest Binary Search Tree Value
1.Question
Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.
Note:
Given target value is a floating point.
You are guaranteed to have only one unique value in the BST that is closest to the target.
2. Implementation
(1) Binary Search
3. Time & Space Complexity
Binary Search: 时间复杂度: O(logn), 空间复杂度: O(1)
Previous298 Binary Tree Longest Consecutive SequenceNext549 Binary Tree Longest Consecutive Sequence II
Last updated