Print all node from distance k

https://ide.codingblocks.com/s/59614 please help me with this code I got three test case failed and one got pass. please suggest me what’s wrong in my code
.

Hi Neeraj, consider the following test case:
Input:

15
12 10 17 22 20 85 74 38 23 64 46 51 65 99 87
10 12 17 20 22 23 38 46 51 64 65 74 85 87 99
1
85 2

Expected Output: 17 20 38 87
Your code’s ouput: 38 87 17

The order of printing is also not correct as well as some nodes are missing.

@sanjeetboora please help me in this code i am unable to find my mistake

@sanjeetboora please help me in debuging