[C++]  DFS + BFS with backEdge
DFS to build the back edges ( backEdge[child] = parent )\n2. BFS from the target as a center until the distance acheives K. \n\nclass Solution {\npublic:\n    v
1. DFS to build the back edges ( backEdge[child] = parent )\n2. BFS from the target as a center until the distance acheives K. \n```\nclass Solution {\npublic:\n    vector<int> distanceK(TreeNode* root, TreeNode* target, int K) {\n        unordered_map<TreeNode*, TreeNode*> backEdge;\n        unordered_set<TreeNode*> visited;\n        vector<int> res;\n        dfs(root, backEdge, target);\n        queue<TreeNode*> que;\n        que.push(target);\n        while(!que.empty() && K >= 0){\n            int s = que.size();\n            while(s--){\n                TreeNode* cur = que.front();\n                int val = cur->val; que.pop();\n                visited.insert(cur);\n                if(K == 0) res.push_back(val); \n                if(!visited.count(backEdge[cur]) && backEdge[cur]) que.push(backEdge[cur]);\n                if(!visited.count(cur->left) && cur->left) que.push(cur->left);\n                if(!visited.count(cur->right) && cur->right) que.push(cur->right);\n            } \n            K--;  \n        }\n        return res;\n    }\n    void dfs(TreeNode* root, unordered_map<TreeNode*, TreeNode*> &backEdge, TreeNode* target){\n        if(!root || (root == target)) return;\n    \n        if(root->left){\n            backEdge[root->left] = root;\n            dfs(root->left, backEdge, target);\n        }\n        if(root->right){\n            backEdge[root->right] = root;\n            dfs(root->right, backEdge, target);\n        }\n    }\n};\n```
[]