Tough Question Made Easy Solution C++ (Recursive) (UPVOTE)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n- O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- O(n) + stack space for recursion calls\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n */\nclass Solution {\npublic:\nunordered_map<TreeNode*,TreeNode*>parent;\n\n    void find_parent(TreeNode* root,TreeNode* par){\n        if(!root)\n        return ;\n\n        parent[root]=par;\n        par=root;\n        if(root->left){\n        find_parent(root->left,par);            \n        }\n        if(root->right){\n            find_parent(root->right,par);\n        }\n\n    }\n\n    vector<int> distanceK(TreeNode* root, TreeNode* target, int k) {\n        find_parent(root,NULL);\n\n        unordered_set<TreeNode*>set;\n        set.insert(NULL);\n\n        queue<TreeNode*>q;\n        q.push(NULL);\n        q.push(target);\n        set.insert(target);\n        int d=0,c=0;\n        vector<int>ans;\n\n\n        while(!q.empty()){\n            TreeNode* curr=q.front();\n            q.pop();\n\n            if(d==k+1){\n                if(curr)\n                ans.push_back(curr->val);\n                \n             \n                break;\n            }\n\n            if(curr==NULL){\n            d+=1;\n            cout<<10<<endl;\n            q.push(NULL);\n            \n            }\n            else{\n            \n\n            if(curr->left and set.find(curr->left)==set.end()){\n                q.push(curr->left);\n                set.insert(curr->left);\n            }\n            if(curr->right and set.find(curr->right)==set.end()){\n                q.push(curr->right);\n                set.insert(curr->right);\n            }\n            if(parent.find(curr)!=parent.end() and set.find(parent[curr])==set.end()){\n                q.push(parent[curr]);\n                set.insert(parent[curr]);\n            }\n            cout<<curr->val<<endl;\n            }\n\n        }\n        while(!q.empty()){\n            auto v=q.front();\n            q.pop();\n            cout<<100<<endl;\n            if(v!=NULL)\n                ans.push_back(v->val);\n            \n        }\n\n       \n\n        return ans;\n        \n    }\n};\n```
['Tree', 'Depth-First Search', 'Breadth-First Search', 'Binary Tree', 'C++']