Sir my code is passing for only two test cases
im not able to print 0 in case of those k which dont have anything to print,please give me hint
Https://ide.codingblocks.com/s/322619
@sauravzt7, actually there is one more thing you are not considering that is to print the values in sorted form (mentioned in the question) , what you can do is instead of printing through the function you can pass a vector to your function and push the node which is at k distance in the vector , if the vector ended up being empty this means no element is present at distance k , so print 0, else sort the vector and print the values