pls look out the problem in my code.
Nodes at a distance k in binary tree
@aman17nov1999 you have to print Kth level nodes from target node, you know the implementation but I see many errors, (an advice : always keep it simple)
- Find the target node
- after finding target node, pass it as root (you passed original root and target as f, then you iterated using root which is wrong, pass only f and call for f->left and f->right)
- to print nodes at distance k which are not in subtree of target, pass distance(basically do as mentor says)
I cannot figure why are you storing the nodes in vector!(please share)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.