there is some bug in my code, its not getting accepted, plz check and revert back the changes
Print All Nodes at K distance
I have edited your code… Try to submit now…
@Bhavya_Goel your this one code is not building the tree correctly.
some of the errors i see in this is you are taking input in preorder[n] inplace of preorder[i] and passing only 0th index value to the function.
first build tree correctly like you build in your first code of this thread and then proceed for kth distance node.
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.