Wrong Answer In 1 case

I think it is because I am taking into account the case where a node has 1 child, but its the right one. I don’t understand how will I come to know whether to put the 1 child on left or right?
Here’s my code:

Please check.

If u get 1 child then i think it should not matter whether u make it a right or left child since we are dealing with levels. although what u have done is also correct.

but why is it showing 1 ans wrong? please check…

I have marked it as mentor attention required because I am not able to find mistake in it . It seems correct to me . If u also mark it as mentor attention required I guess it will be resolved.

I don’t know how to mark it as mentor-support required…

I have marked it or u can mark it as resolved and ask ur mentor directly.

Please check the code. I think its all right. The last TA marked it as mentor attention but no reply. Please help.

@Doctor_Insult try taking sum as long long int

Hi @Doctor_Insult on line 55 you are sending 2 as the level always, send k as the function argument, like this:
cout<<tree1.sum_at_level_k(tree1.get_root(), k);

1 Like

Thanks a lot!!! It really was such a small mistake…

1 Like