Code Not Working

The code is not accepted by the test cases , but is working for the test given in the question.
Please help me where in realising where my code is wrong.
Thank You!!.

print_element_from_target_to_k_level()
in this function
if root!=target then your code will not work correctly

if you reach at leaf node then
it’s left and right both return -1 hence according to your code it also return -1 and hence every node return -1

so you have to consider leaf node case seperately

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.