暴力得很
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
private:
set<int>ss;
public:
bool findTarget(TreeNode* root, int k) {
if(!root) return 0;
if(ss.count(k-root->val))
{
return 1;
}
ss.insert(root->val);
return findTarget(root->left,k) ||findTarget(root->right,k);
}
};