← 返回 meta 的题目列表Closest Value in Binary Search Tree to Target
类型:online_judge
meta
Given a binary search tree and a target value, implement a function to find the value in the binary search tree that is closest to the target. The input is the root of the binary search tree and a target value, each node's value in the BST is unique. Please return the closest value to the target. The tree has at least one node. Example: Input root node as: [4, 2, 5, 1, 3], target value is 3.714286, the output should be 4.
Example
Input
4 2 5 1 3
3.714286