Node at distance K

Failing 2 testcases-https://ide.geeksforgeeks.org/2Indrrylf7

hi @darkthunderassassin_818a6616c3c74f13
I have already shared the corrected code on other chat…
There are 2 mistakes in ur code…

  1. U have to print the nodes in the increasing order
  2. If there is no node print 0

So use an array/vector then sort them and print the final ans instead of directly printing the nodes…

refer this code -->

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.