Distance k from a node(problem)

https://ide.codingblocks.com/s/345890.
the code is working fine but it is failing for 1 testcase.I am not finding any type of logical errors.Can you please check
the code once?

hello @bommareddyjyothiswaroopreddy you code is falling in two test cases .
this is because it is mentioned in the question that you have print output in the sorted form .
this the error in your code .
you can simply do this by adding this to any data structure and then sorting it .
Happy Learning !!

i sorted it.still failing in 1 case.https://ide.codingblocks.com/s/346110

@bommareddyjyothiswaroopreddy yes but now your code is not producing the complete output .

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.