Print all nodes at distance k

i am not getting the correct ans on submisson