class Solution {
public:
bool findTarget(TreeNode* root, int k) {
queue<TreeNode> Q;
vector<int> V;
if (root != NULL)
{
Q.push(*root);
while (!Q.empty())
{
TreeNode livenode = Q.front();
Q.pop();
V.push_back(livenode.val); if (livenode.left != NULL)
{
Q.push(*livenode.left);
}
if (livenode.right != NULL)
{
Q.push(*livenode.right);
}
} sort(V.begin(), V.end()); for (int i = ; i < V.size(); i++)
{
for (int j = ; j < V.size(); j++)
{
int x = V[i];
int y = V[j];
if (x + y < k)
{
continue;
}
if (x + y == k&&i != j)
{
return true;
}
if (x + y > k)
{
break;
}
}
}
}
return false;
}
};