题目:
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.
Example 1:
Input:
5
/ \
3 6
/ \ \
2 4 7
Target = 9
本文详细介绍了LeetCode第653题——二叉搜索树中两数之和的问题,提供了解题思路及O(n)复杂度的解决方案,通过建立哈希表辅助查找,实现找到目标和的两个元素。
题目:
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.
Example 1:
Input:
5
/ \
3 6
/ \ \
2 4 7
Target = 9
1292

被折叠的 条评论
为什么被折叠?