0270. Closest Binary Search Tree Value

https://leetcode.com/problems/closest-binary-search-tree-value

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:

Example 2:

Constraints:

  • The number of nodes in the tree is in the range [1, 104].

  • 0 <= Node.val <= 109

  • -109 <= target <= 109

ac

Last updated

Was this helpful?