653. Two Sum IV - Input is a BST
题目描述
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.
|
|
|
|
Seen this question in a real interview before? YesNo
题目大意
在搜索二叉树内找到两个数和为target
解题思路
1、通过遍历二叉树,将二叉树转换为字典
2、遍历字典,寻找是否有两个数和为target
代码
|
|