Please help me to debug my code. Sample test case is passed but cannot pass two test cases after submitting
Print all nodes at a distance k from a given node
You need to print the nodes in sorted order. You can create a vector to store all the nodes at distance k and then sort it before printing final answer.
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.
Update: 3/4 test cases being passed
@mohammadabdullahjawwad read problem statement carefully you have to Print 0 if no such node exist at distance k.
Made the change. Still one test case not being passed. Please help.
your code was still not printing 0 so i have made a small change in your code look at this https://ide.codingblocks.com/s/250005
Thanks, it worked. But why wasn’t my code printing zero, result vector was anyway empty. Please explain
@mohammadabdullahjawwad you were checking if ans exist then print else print 0 but your answer was never returning NULL.
But the return type of answer was int, how could it return NULL?
i mean you were cheking if(answer(---------)) then print but your answer was never returning 0 so it will always go in the first if condition and hence does not print 0.
mark this doubt as resolved if you don’t have any further queries.
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.