Wrong answer for sample cases

I tested my code many times and it working fine but my answer is always null.

@anujydv Could you provide us a screenshot or an example to help us understand what is exactly happening ?

Hey I think your codes logic is fundamentally flawed for this to happen. Firstly you are increasing the number of nodes to 9 from the orignal 7 , hence some how modifying the tree. You only need to allocate nodes to the next pointer and not modify the entire tree. Please correct your implementation. The statement tmp->root = NULL is an indication on how you are implementing the logic wrongly.

1 Like

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.