Print all nodes at distance k from given node problem

https://ide.geeksforgeeks.org/1LdSgp7JKl------The code is not showing output, what is the error in the code

Hey @AbhishekAhlawat1102
you are doing wrong .
Root node is always null.
and Bulid is also wrong

https://ide.geeksforgeeks.org/ozEr7Na0Oh---- I ahve corrected build and root is now no longer null, the code is running fine for sample input but upon submission only 2 out of 4 test cases are passing can u point out the errors in the code and make corrections?

@AbhishekAhlawat1102
Try for this 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
20 2
correct output
17 58
your code gives
85 17