270. Closest Binary Search Tree Value
https://leetcode.com/problems/closest-binary-search-tree-value/
BST上找与给定值最接近的。利用BST性质找target,cur->val比target小时结果只可能是当前点或右树的结点,遍历右树;反之则遍历左树,每个遍历到的结点都是候选。
Last updated
Was this helpful?
https://leetcode.com/problems/closest-binary-search-tree-value/
BST上找与给定值最接近的。利用BST性质找target,cur->val比target小时结果只可能是当前点或右树的结点,遍历右树;反之则遍历左树,每个遍历到的结点都是候选。
Last updated
Was this helpful?