270. Closest Binary Search Tree Value 二叉搜索树中,距离目标值最近的节点

Given the root of a binary search tree and a target value, return the value in the BST that is closest to the target.

 

Example 1:

270. Closest Binary Search Tree Value 二叉搜索树中,距离目标值最近的节点

Input: root = [4,2,5,1,3], target = 3.714286
Output: 4

Example 2:

Input: root = [1], target = 4.428571
Output: 1

 

上一篇:536. Construct Binary Tree from String 从括号字符串中构建二叉树


下一篇:257.binary-tree-paths