can you please let me know where my code is lagging
Nodes at a distance k from the target node
@rahul.aggarwal000005
There are two mistakes in your code
- line 65 should be printkDown(root->right,k-l-1); You have to go right side of root
- You have missed the case when there is no such node, in that case you’ve to print “0”. Just write if(v.size()==0){ cout<<“0”<<endl; continue; } after line 101
Your code will work fine.