Skip to content

Latest commit

 

History

History
56 lines (35 loc) · 1.27 KB

File metadata and controls

56 lines (35 loc) · 1.27 KB

中文文档

Description

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:

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

Example 2:

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

 

Constraints:

  • The number of nodes in the tree is in the range [1, 104].
  • 0 <= Node.val <= 109
  • -109 <= target <= 109

Solutions

Python3

Java

...