Print all nodes at distance k from a given node


One test case is not passing. Check out and resolve it.

@anishanand3733
here you are checking only for target node if it is present int the array or not.
But there may be a possibility lets suppose tree is of height=2, but k is 1000. then there is no possibility so you have to print β€œ0” in that case also.
So just check if result.size()==0 then also proint β€œ0”

I hope you have got your mistake now.
Please mark the doubt as resolved if it is clear now.

1 Like

hi anish. we don’t know each other but i am asking you for a help. can you please give your 100% off coupon. brother i really want to do the Interview Prep Java Course.
Please.

I have already used it to buy the course.

bro, can u still share the code?