PRINT ALL NODES AT K


What is the error in this code? Half the test cases are not getting passed.

@AbhilashaBansal
You have missed the case when node at distance k doesn’t exist. In that case you have to print 0.
Consider this testcase
4
60 65 50 70
50 65 60 70
2
60 1
65 5
output should be
65 70
0
Your code is printing “65 70”

Yes, that was the mistake. Thanks for your help.